Android calendar gets month day minute seconds

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.