20145109 《Java程序设计》第七周学习总结

20145109 《Java程序设计》第七周学习总结

Chapter 13 Time & Date

Date

System.currentTimeMillis()

return LONG. It's the number of ms from 1970.1.1 0:0:0.

getDateInstance()
getTimeInstance()
getDateTimeInstance()

return detailed date & time.

SimpleDateFormat: self-defined format:

DateFormat dateFormat = new SimpleDateFormat("EE-MM-dd-yyyy");
System.out.println(dateFormat.format(new Date()));

Calendar

Calendar calendar = Calendar.gerInstance();
out.println(calendar.get(Calendar.YEAR));

calendar.set(2014, Calendar.MAY, 26); 

calendar.add(Calendar.HOUR, 3);

calendar.roll(Calendar.DATE, 1); // only handle the date, month won't modify
posted @ 2016-04-17 22:54  Christen  阅读(156)  评论(1编辑  收藏  举报