1.Calendar class calendar, time information packaged as a static member variables, is an abstract class.
Get the current time
1 // get the current time 2 Calendar C = Calendar.getInstance (); . 3 System.out.println (C); // a java.util.GregorianCalendar [Time = 1,577,343,828,788,
2. The method of operating time obtained by:
2.1 get
1 // current operating time 2 int m = c.get (the Calendar.MONTH); . 3 System.out.println (m); // get the month, it should +1
2.2 add
1 // current time plus or minus 2 c.add (the Calendar.MONTH, 1);
2.3 gettime
java cal.get (Calendar.DATE) and the difference between the Calendar.DATE: Calendar.DATE this thing is not the log, which is just a constant java Calendar defined, corresponding to the date for taking out key,
1 // get the current time 2 Calendar C = Calendar.getInstance (); . 3 c.getTime (); // get // Date object month from 0, . 4 System.out.println (C); . 5 the SimpleDateFormat CC = new new the SimpleDateFormat ( "the mM-dd-YYYY HH: mm: the SS" ); . 6 System.out.println (cc.format (c.getTime ())); // month obtained at this time is normal month 2019-12-26 15: 17: 640
2.4set set to the current time value specified
1 // get the current time 2 Calendar C = Calendar.getInstance (); . 3 c.set (1992,. 9, 02, 12 is, 12 is, 12 is ); . 4 // to set the current time value specified . 5 the System.out. println (c);
DATE / DATE OF MONTH: The first few days were a month