java.util.Calendar的用法--java基础
百度广告
public class ShowDate {
public static void main(String args) {
Date trialTime = new Date();
// print out a bunch of interesting things
System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR));
System.out.println("DATE: " + calendar.get(Calendar.DATE));
System.out.println("DAY_OF_YEAR: " + calendar.get(Calendar.DAY_OF_YEAR));
System.out.println("DAY_OF_WEEK_IN_MONTH: " + calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH));
System.out.println("HOUR: " + calendar.get(Calendar.HOUR));
System.out.println("MINUTE: " + calendar.get(Calendar.MINUTE));
System.out.println("MILLISECOND: " + calendar.get(Calendar.MILLISECOND));
System.out.println("DST_OFFSET: " + (calendar.get(Calendar.DST_OFFSET)/(60*60*1000)));
System.out.println("Current Time, with hour reset to 3");
calendar.set(Calendar.HOUR, 3);
System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR));
System.out.println("DATE: " + calendar.get(Calendar.DATE));
System.out.println("DAY_OF_YEAR: " + calendar.get(Calendar.DAY_OF_YEAR));
System.out.println("DAY_OF_WEEK_IN_MONTH: " + calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH));
System.out.println("HOUR: " + calendar.get(Calendar.HOUR));
System.out.println("MINUTE: " + calendar.get(Calendar.MINUTE));
System.out.println("MILLISECOND: " + calendar.get(Calendar.MILLISECOND));
System.out.println("DST_OFFSET: " + (calendar.get(Calendar.DST_OFFSET)/(60*60*1000))); // in hours
}
编辑推荐:
温馨提示:因考试政策、内容不断变化与调整,长理培训网站提供的以上信息仅供参考,如有异议,请考生以权威部门公布的内容为准! (责任编辑:长理培训)
点击加载更多评论>>