首页 > 代码库 > java calendar 字段含义输出
java calendar 字段含义输出
@Test public void testCalendar(){ Calendar c=Calendar.getInstance(); c.set(2000, 3, 13, 14, 15, 16); c.set(Calendar.MILLISECOND, 123);//不设置时随机输出 System.out.println(FormatUtils.dateTimeString(c.getTime())); System.out.println(c.get(Calendar.YEAR)+"<-Calendar.YEAR\n " +c.get(Calendar.MONTH)+"<-Calendar.MONTH\n " +c.get(Calendar.WEEK_OF_YEAR)+"<-Calendar.WEEK_OF_YEAR\n " +c.get(Calendar.WEEK_OF_MONTH)+"<-Calendar.WEEK_OF_MONTH\n " +c.get(Calendar.DAY_OF_WEEK)+"<-Calendar.DAY_OF_WEEK\n " +c.get(Calendar.DAY_OF_MONTH)+"<-Calendar.DAY_OF_MONTH\n " +c.get(Calendar.DAY_OF_YEAR)+"<-Calendar.DAY_OF_YEAR\n " +c.get(Calendar.DAY_OF_WEEK_IN_MONTH)+"<-Calendar.DAY_OF_WEEK_IN_MONTH\n " +c.get(Calendar.HOUR_OF_DAY)+"<-Calendar.HOUR_OF_DAY\n " +c.get(Calendar.HOUR)+"<-Calendar.HOUR\n " +c.get(Calendar.MINUTE)+"<-Calendar.MINUTE\n " +c.get(Calendar.SECOND)+"<-Calendar.SECOND \n" +c.get(Calendar.MILLISECOND)+"<-Calendar.MILLISECOND \n"); }
输入结果
2000-04-13 14:15:16
2000<-Calendar.YEAR
3<-Calendar.MONTH
16<-Calendar.WEEK_OF_YEAR
3<-Calendar.WEEK_OF_MONTH
5<-Calendar.DAY_OF_WEEK
13<-Calendar.DAY_OF_MONTH
104<-Calendar.DAY_OF_YEAR
2<-Calendar.DAY_OF_WEEK_IN_MONTH
14<-Calendar.HOUR_OF_DAY
2<-Calendar.HOUR
15<-Calendar.MINUTE
16<-Calendar.SECOND
123<-Calendar.MILLISECOND
注:Calendar.DAY_OF_WEEK_IN_MONTH 含义为 :月份中1-7为第1周,8-14第2周……依次类推
java calendar 字段含义输出
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。