The Calendar class is also in the java.util package. You can initialize a calendar object using the static method getInstance() of the Calendar class, for example:
Calendarcalendar=Calendar.getInstance();
The calendar object can then call methods:
publicfinalvoidset(intyear,intmonth,intdate)publicfinalvoidset(intyear,intmonth,intdate,inthour,intminute)publicfinalvoidset(intyear,intmonth,intdate,inthour,intminute,intsecond)
Turn the calendar to any time. When the parameter year is negative, it means BC (BC in the real world).
The calendar object calls the method public int get(int field) to obtain information about the year, month, hour, week, etc. The valid value of the parameter field is specified by the static constant of Calendar.
For example:
calendar.get(Calendar.MONTH);
Returns an integer. If the integer is 0, it means that the current calendar is in January, if the integer is 1, it means that the current calendar is in February, etc.
For example:
calendar.get(Calendar.DAY_OF_WEEK);
Returns an integer if the integer is 1 for Sunday, 2 for Monday, and so on, 7 for Saturday.
Calendar objects call public long getTimeInMillis() to express time in milliseconds.