Java-calendar class +

Source: Internet
Author: User

Package Com.day10.Calendar;

Import Java.util.Calendar;

public class Demo1calendar {

/**
* @param args
* Common objects (add () and set () methods of the Calendar Class) (Master)
* A: Member method
* public void Add (int field,int amount)
* Public final void set (int year,int month,int date)
* B: Case Demo
* Member methods of the Calendar class are used
*/
public static void Main (string[] args) {
Calendar c=calendar.getinstance ();//parent Class reference to child class object
C.add (Calendar.month, 1);//forward minus or backward for the specified field
C.set (calendar.year,2000);//Modify the specified field
C.set (2000, 7,8);//Modified Date
System.out.println (C.get (calendar.year) + "year" + (C.get (calendar.month) +1) + "month" +
C.get (Calendar.day_of_month) + "Day" +getweek (C.get (Calendar.day_of_week)));

}
public static String Getweek (int week)
{
String[] arr={"", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
return Arr[week];
}

}

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.