package com.ecode.li.date; import java.io.filenotfoundexception; import java.io.fileoutputstream; import java.io.ioexception; import java.io.objectoutputstream; import java.util.Calendar; import java.util.Date; import java.util.gregoriancalendar; public class calendartest { /**
* calendar class use * * @param */
public static void main (String[] args) { // instantiation calendar cale = calendar.getinstance (); if (cale
Instanceof gregoriancalendar) { system.out.println ("This shows the creation of a GregorianCalendar class object, and the class is a subclass of the calendar abstract class "); } // from a Get Date object in calendar object dAte date = cale.gettime (); /* * will Date Object reacts to a Calendar object, calendar/gregoriancalendar no constructors can accept * date object So we need to get an instance first and then set Date object */ cale.settime (date); // Current year int year = cale.get (calendar.year);   SYSTEM.OUT.PRINTLN (year); // current month calendar.month starting from 0 int month = (Cale.get (calendar.month)) + 1; system.out.println
(month); // days of the current month: that is, the current day int day_of_month = Cale.get (calendar.day_of_month); // Calendar.DAY_OF_MONTH and calendar.date is equivalent to int dates = cale.get (calendar.date); System.oUT.PRINTLN (dates); system.out.println (day_of_month); // Current time: HOUR_ Of_day-24-hour int hour24 = cale.get (calendar.hour_of_day); //  HOUR-12-hour int hour12 = cale.get (calendar.hour); System.out.println (HOUR24); system.out.println (hour12); // current Score
int minute = cale.get (Calendar.minute); // Current SEC int second = cale.get (Calendar.second); system.out.println (minute) ; system.out.println (second); // week calendar.day_of_ Week Digital (1~7) (Sunday ~ Saturday) int day_of_week = Cale.get (calendar.day_of _week) - 1; system.out.println (day_of_week); // first weeks of the current year int week_of_year = Cale.get (calendar.week_of_year); system.out.println ( Week_of_year); // //The number of weeks in the current month // int week_of_month = cale.get (calendar.week_of_month); // // //the first few weeks of the current month // int day_of_week_in_month = cale.get (Calendar.DAY_OF _week_in_month); // // //The first days of the current year
// int day_of_year = cale.get (calendar.day_of_year); } }