首页 > 代码库 > 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 字段含义输出