The static method of the Calendar class getInstance () can initialize a Calendar Object: Calendar now = Calendar. getInstance ();
You can use the following three methods to set the calendar to any time:Set (int year, int month, int date)Set (int
Date dNow = new Date (); // current timeDate dBefore = new Date ();
Calendar calendar = Calendar. getInstance (); // obtain the CalendarCalendar. setTime (dNow); // assign the current time to the calendarCalendar. add (Calendar. DAY_OF_MONTH,-1); //
The source code is as follows: Import java. util .*;
Public class showdate {
Public static void main (string [] ARGs ){Calendar calendar = new gregoriancalendar ();Date trialtime = new date ();Calendar. settime (trialtime );
// Print out a bunch of
Source: http://blog.csdn.net/zerogotosum/article/details/1671314What exactly is a Calendar? Chinese translation is the calendar, then we can immediately think of our lives in the Yang (male) calendar, Yin (agricultural) calendar of the points. What
(The date class will be introduced at the end of the article, assuming interest, and can go straight to the last reading)What exactly is a Calendar? Chinese translation is the calendar, then we can immediately think of our lives in the Yang (male)
(The date class will be introduced at the end of the article, assuming interest, and can go straight to the last reading)What exactly is a Calendar? Chinese translation is the calendar, then we can immediately think of our lives in the Yang (male)
(The date class will be introduced at the end of the article, assuming interest, and can go straight to the last reading)What exactly is a Calendar? Chinese translation is the calendar, then we can immediately think of our lives in the Yang (male)
(The date class will be introduced at the end of the article, assuming interest, and can go straight to the last reading)What exactly is a Calendar? Chinese translation is the calendar, then we can immediately think of our lives in the Yang (male)
1. calculate the maximum number of days of calendar month. getinstance (); time. clear (); time. set (calendar. year, year); // year is inttime. set (calendar. month, I-1); // note that the default January Calendar Object is 0 int day = time.
Calendar class of java
The Calendar in java is often ignored during development. This blog summarizes this class, which is helpful for later project use periods.Functions of the Calendar constant (field)
Calendar cal = Calendar. getInstance (); cal.
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.