List of usage examples for java.util GregorianCalendar GregorianCalendar
public GregorianCalendar()
GregorianCalendar
using the current time in the default time zone with the default Locale.Category#FORMAT FORMAT locale. From source file:Main.java
public static void main(String[] args) { GregorianCalendar cal = new GregorianCalendar(); cal.set(Calendar.ERA, GregorianCalendar.BC); System.out.println(cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { GregorianCalendar gc = new GregorianCalendar(); System.out.println("Current Date: " + gc.getTime()); // Add 1 year gc.add(Calendar.YEAR, 1);/*from www .ja v a2 s . c om*/ System.out.println(gc.getTime()); // Add 15 days gc.add(Calendar.DATE, 15); System.out.println(gc.getTime()); }
From source file:Main.java
public static void main(String[] args) { GregorianCalendar cal = new GregorianCalendar(); cal.set(Calendar.ERA, GregorianCalendar.AD); System.out.println(cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { // create a new Main object GregorianCalendar cal = new GregorianCalendar(); // print the class of cal System.out.println(cal.getClass()); }
From source file:Main.java
public static void main(String[] a) { GregorianCalendar calendar = new GregorianCalendar(); calendar.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); int day = calendar.get(Calendar.DAY_OF_WEEK); switch (day) { case Calendar.MONDAY: System.out.println(Calendar.MONDAY); break;/*from w ww . j ava2 s . c o m*/ case Calendar.TUESDAY: System.out.println(Calendar.TUESDAY); break; default: System.out.println("others"); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { Calendar cal = new GregorianCalendar(); // Get the components of the time int hour12 = cal.get(Calendar.HOUR); // 0..11 int hour24 = cal.get(Calendar.HOUR_OF_DAY); // 0..23 int min = cal.get(Calendar.MINUTE); // 0..59 int sec = cal.get(Calendar.SECOND); // 0..59 int ms = cal.get(Calendar.MILLISECOND); // 0..999 int ampm = cal.get(Calendar.AM_PM); // 0=AM, 1=PM }
From source file:Main.java
public static void main(String[] args) { GregorianCalendar gregorianCalendar = new GregorianCalendar(); ZonedDateTime d = gregorianCalendar.toZonedDateTime(); System.out.println(d);// w w w . jav a 2 s . com }
From source file:Main.java
public static void main(String[] args) { ZonedDateTime gregorianCalendarDateTime = new GregorianCalendar().toZonedDateTime(); GregorianCalendar gc = GregorianCalendar.from(gregorianCalendarDateTime); System.out.println(gc);/*from www . j a v a2s . c o m*/ }
From source file:Main.java
public static void main(String args[]) { Calendar cal1 = new GregorianCalendar(); Calendar cal2 = new GregorianCalendar(); cal1.set(2010, 12, 1);//from w w w. j a v a 2s . c o m cal2.set(2011, 9, 31); System.out.println("Days= " + daysBetween(cal1.getTime(), cal2.getTime())); }
From source file:Main.java
public static void main(String args[]) { Calendar c1 = new GregorianCalendar(); Calendar c2 = new GregorianCalendar(); c1.set(2000, 12, 12, 0, 0, 0);/*from ww w .j a v a2s. c om*/ c2.set(2001, 12, 12, 0, 0, 0); System.out.println(daysBetween(c1.getTime(), c2.getTime()) + " day(s) between " + args[0] + "-" + args[1] + "-" + args[2] + " and " + args[3] + "-" + args[4] + "-" + args[5]); }