其他分享
首页 > 其他分享> > 具体时间

具体时间

作者:互联网

package ten;

import java.util.GregorianCalendar;

public class Calendar {
   public static void main(String[] args) {
       GregorianCalendar gregorianCalendar = new GregorianCalendar();
       gregorianCalendar.set(2022,6,15,20,30,07);
       System.out.println("Year\tMonth\tDate\tHour\tHour24\tMinute\tSecond");
       System.out.println(gregorianCalendar.get(java.util.Calendar.YEAR)+"\t"+
               gregorianCalendar.get(java.util.Calendar.MONTH)+"\t"+
               gregorianCalendar.get(java.util.Calendar.DATE)+"\t"+
               gregorianCalendar.get(java.util.Calendar.HOUR)+"\t"+
               gregorianCalendar.get(java.util.Calendar.HOUR_OF_DAY)+"\t"+
               gregorianCalendar.get(java.util.Calendar.MINUTE)+"\t"+
               gregorianCalendar.get(java.util.Calendar.SECOND));
       System.out.println("Days of week:"+gregorianCalendar.get(java.util.Calendar.DAY_OF_WEEK));
       System.out.println("Days of month:"+gregorianCalendar.get(java.util.Calendar.DAY_OF_MONTH));
       System.out.println("Days of year:"+gregorianCalendar.get(java.util.Calendar.DAY_OF_YEAR));
       System.out.println("week of month"+gregorianCalendar.get(java.util.Calendar.WEEK_OF_MONTH));
       System.out.println("week of year"+gregorianCalendar.get(java.util.Calendar.WEEK_OF_YEAR));
  }
}
 

标签:java,get,System,util,时间,具体,Calendar,gregorianCalendar
来源: https://www.cnblogs.com/wyx-5555/p/16380772.html