Java Calendar class

Source: Internet
Author: User

The ~calendar class is an abstract class that provides a number of transitions between a specific moment and a set of calendar fields such as Year,month,day_of_month,hour
Method, and provides methods for manipulating calendar fields (such as getting the date of the next week), which can be expressed instantaneously as a millisecond value, which is a distance from the calendar element (January 1, 1970
Offset of 00:00:00.000)
~ Like other locale-sensitive classes, Calendar provides a class method getinstance, which has obtained a generic object of this type. Calendar's
GETINSTANCEFANGFA Fanhui Yige Calendar object with the current date and time initialized

public static Calendar getinstance ()
Public final Date GetTime ()
Public final void SetTime (date date)
public int get (int field)
Public finalvoid Set (int year,int month,int date)
public boolean befor (Object when)
public boolean aafter (Object when)
public int CompareTo (Calendar anothercalendar)

ImportJava.util.Calendar; Public classCalendardemo { Public Static voidMain (string[] args) {//TODO auto-generated Method StubCalendar Calendar =calendar.getinstance (); System.out.print (Calendar.get (calendar.year)+ "Year"); System.out.print (Calendar.get (calendar.month)+ "Month"); System.out.print (Calendar.get (calendar.date)+ "Day"); System.out.print (Calendar.get (calendar.hour_of_day)+":");//24-hour systemSystem.out.print (Calendar.get (Calendar.minute) + ":");        System.out.println (Calendar.get (Calendar.second)); Calendar.set (Calendar.year,By 2020); System.out.println (Calendar.get (calendar.year)+ "Year"); System.out.println (Calendar.gettimeinmillis ());//the number of seconds that have passed since 1970 to now    }}

Java Calendar class

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.