Thanks for the hint. Here was my attempt. The requirements are expressed within the switch statement. I'm not quite sure how to capture the current date. Currently I'm posting just the time. Any additional help would be great.
import java.util.*;
import java.text.*;
class GeekWatch {
public static void main (
String args[]) {
int x = Integer.parseInt(args[0]);
DateFormat timeFormat = DateFormat.getTimeInstance();
Date tf = new Date();
Calendar cal = Calendar.getInstance();
long mill = tf.getTime();
switch (x) {
case 0:
System.out.println("milliseconds since January 1, 1970: \t" + mill);
break;
case 1:
long seconds =mill/1000;
System.out.println("number of seconds since January 1, 1970: \t" + seconds);
break;
case 2:
long day = ((((mill/1000)/60)/60)/24);
System.out.println("number of days since January 1, 1970: \t" + day);
break;
case 3:
String time = timeFormat.format(cal.getTime());
System.out.println("current date and time: \t" + time);
break;
}
}
}