// time_of_day.java just use Date and Calendar classes import java.util.*; public class time_of_day { double t1, t2; // time in milliseconds double waste = 0.0; public time_of_day() { System.out.println("time_of_day from Java"); System.out.println(); GregorianCalendar now = new GregorianCalendar(); // now System.out.println(now.toString()); // whole mess System.out.println(); System.out.println(now.get(GregorianCalendar.MONTH)+"/"+ now.get(GregorianCalendar.DATE)+"/"+ now.get(GregorianCalendar.YEAR)); System.out.println(now.get(GregorianCalendar.HOUR)+":"+ now.get(GregorianCalendar.MINUTE)+":"+ now.get(GregorianCalendar.SECOND)); System.out.println(now.get(GregorianCalendar.MILLISECOND)+ " milliseconds"); System.out.println(); // get time, waste time, get time t1 = System.currentTimeMillis(); System.out.println("t1="+t1); for(int i=0; i<100000; i++) waste = waste + Math.sin(1.723)*Math.cos(1.113)/394.247; if(waste>0.0) waste = 0.0; t2 = System.currentTimeMillis(); System.out.println("t2="+t2+" t2-t1="+(t2-t1)+" milliseconds"); Date dt = new Date(); System.out.println("getTime() = "+dt.getTime()+" seconds since epoc"); } public static void main (String[] args) { new time_of_day(); } }