Reproduced from the Internet, to be backed up
Start using the new Date () test and get it through Date.getmonth (), and Date.getday (), but later found out that the two jdk1.1 versions of the interview are not now, and the results are incorrect. int month = (Date.get (calendar.month)) +1;
int day = Date.get (calendar.day_of_month);
Get the current month and date
Tried it, and it was right.
Later, I looked at the Java Doc Document and the month field explained the following
Field number for Get and set indicating the month. This is a calendar-specific value. The "the" the "the" is January which is 0; The last depends on the number of months in a.
The value of this field is only a property field value that describes get () to obtain the month
The following are for obtaining other:
Calendar CD = Calendar.getinstance ();
int YY = Cd.get (calendar.year);
int MM = Cd.get (calendar.month) +1;
int DD = Cd.get (calendar.date);
int HH = Cd.get (Calendar.hour);
int NN = Cd.get (Calendar.minute);
int SS = Cd.get (Calendar.second);
int MI = Cd.get (Calendar.millisecond);
Calendar cal = Calendar.getinstance ();
When the year before last
int year = Cal.get (calendar.year);
Current month
int month = (Cal.get (calendar.month)) +1;
Days of the current month: current day
int day_of_month = Cal.get (calendar.day_of_month);
Current time: hour_of_day-24-hour system; HOUR-12-hour system
int hour = Cal.get (Calendar.hour_of_day);
Current score
int minute = Cal.get (Calendar.minute);
Current seconds
int second = Cal.get (Calendar.second);
0-a.m.; 1-PM
int ampm = Cal.get (CALENDAR.AM_PM);
The week ordinal of the current year
int week_of_year = Cal.get (calendar.week_of_year);
The week ordinal of the current month
int week_of_month = Cal.get (calendar.week_of_month);
The day ordinal of the current year
int day_of_year = Cal.get (calendar.day_of_year);