Start with the new Date () test and get through Date.getmonth (), and Date.getday (), but later found that the two jdk1.1 versions of the visit are now unused and the results are incorrect.
int month = (date. Get(calendar.month)) +1; int day = date. Get
Get the current month and date
Tried it, and it was right.
After reviewing the Java Doc documentation, the month field is explained below
Field number for get
and set
indicating the month. This is a calendar-specific value. The first month of the year is which are 0; the last depends on the number of JANUARY
months in a year.
The value of this field simply describes the property field value of Get () to get the
Here's how to get other:
Calendar CD =calendar.getinstance ();intYY = CD.Get(calendar.year);intMM = CD.Get(Calendar.month) +1;intDD = CD.Get(calendar.date);intHH = CD.Get(calendar.hour);intNN = CD.Get(Calendar.minute);intSS = CD.Get(Calendar.second);intMI = CD.Get(Calendar.millisecond); Calendar Cal=calendar.getinstance (); //Current year intYear = Cal.Get(calendar.year); //Current Month intmonth = (cal.Get(Calendar.month)) +1; //days of the current month: Current day intDay_of_month = Cal.Get(Calendar.day_of_month); //Current time: Hour_of_day-24 hour system; HOUR-12 hour system inthour = Cal.Get(Calendar.hour_of_day); //Current points intminute = Cal.Get(Calendar.minute); //Current seconds intSecond = Cal.Get(Calendar.second); //0-morning; 1-PM intAMPM = Cal.Get(CALENDAR.AM_PM); //the first week of the current year intWeek_of_year = Cal.Get(calendar.week_of_year); //the week ordinal of the current month intWeek_of_month = Cal.Get(Calendar.week_of_month); //the day ordinal of the current year intDay_of_year = Cal.Get(Calendar.day_of_year);
Android calendar gets month day minute seconds