1、毫秒显示
import java.util.Date;
?
long date = new Date().getTime();
System.out.println("从很早的时间到现在总的毫秒数:"+ date +"毫秒");
?
?
2、时间格式显示
import java.util.Calendar;
?
public class SysDate {
?public static void main(String[] args) {
? Calendar c = Calendar.getInstance();
? System.out.println("年:" + c.get(Calendar.YEAR));
? System.out.println("月:" + (c.get(Calendar.MONTH) + 1));
? System.out.println("日:" + c.get(Calendar.DAY_OF_MONTH));
? System.out.println("24时制小时:" + c.get(Calendar.HOUR_OF_DAY));
? System.out.println("12时制:" + c.get(Calendar.HOUR));
? System.out.println("分:" + c.get(Calendar.MINUTE));
? System.out.println("秒:" + c.get(Calendar.SECOND));
? System.out.println("今天是一年中的第:" + c.get(Calendar.DAY_OF_YEAR) + "天");
?}
}?