The abstract class Calendar provides a set of methods that allow you to convert time in milliseconds to some useful time component. The calendar cannot create objects directly, but you can use the static method getinstance () to get the Calendars object representing the current date.
Methods of the Calendar class refer to API (Application programming Interface)
The Calendar class uses flexibility to obtain various forms of expression of time and date. The following time will be pushed back 100 days, the date of the year, month, day format.
Calendar s=calendar.getinstance (); S.add (calendar.day_of_year, 100); System.out.print (S.get (calendar.year) + "year"); System.out.print (S.get (calendar.month) + "month"); System.out.println (S.get (calendar.day_of_month) + "number");
The results are as follows:
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/8A/1B/wKioL1gnFW7iFoJ8AAAH8mIp0lY785.png-wh_500x0-wm_3 -wmp_4-s_1614681890.png "title=" capture. PNG "alt=" Wkiol1gnfw7ifoj8aaah8mip0ly785.png-wh_50 "/>
Use calendar to get your computer's current calendar:
Date T=new date (); Calendar s=calendar.getinstance (); int a=s.getactualmaximum (calendar.day_of_month); System.out.println ("t \ t two \ t three \ Four \ five \ t six"), S.set (Calendar.day_of_month, 1); int w=s.get (Calendar.day_of_week); for ( int i=1;i<w;i++) {System.out.print ("\ t");} for (int j=1;j<=a;j++) {System.out.print (j+ "\ t"); if (S.get (Calendar.day_of_week) ==calendar.saturday) { System.out.println ();} S.add (calendar.day_of_month,1);}
The resulting format is as follows:
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/8A/1F/wKiom1gnFeXii29ZAAAMheeaeLU711.png-wh_500x0-wm_3 -wmp_4-s_1116912570.png "title=" Capture 2. PNG "alt=" Wkiom1gnfexii29zaaamheeaelu711.png-wh_50 "/>
Calendar class to print calendars using the Calendar class