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) { Calendar cal = new GregorianCalendar(); System.out.println(cal.getTime()); cal.set(Calendar.AM_PM, Calendar.AM); System.out.println(cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = new GregorianCalendar(); System.out.println(cal.getTime()); cal.set(Calendar.AM_PM, Calendar.PM); System.out.println(cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { Calendar today = new GregorianCalendar(); Calendar purchased = new GregorianCalendar(); purchased.add(Calendar.DAY_OF_MONTH, 1); Calendar lastActDate = new GregorianCalendar(); lastActDate.setTimeInMillis(today.getTimeInMillis() - purchased.getTimeInMillis()); }
From source file:MainClass.java
public static void main(String[] a) { GregorianCalendar calendar = new GregorianCalendar(); calendar.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); }
From source file:MainClass.java
public static void main(String[] a) { GregorianCalendar calendar = new GregorianCalendar(); calendar.roll(Calendar.MONTH, false); // Go back a month System.out.println(calendar.get(Calendar.MONTH)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { GregorianCalendar gc = new GregorianCalendar(); gc.setLenient(false);/*from w ww. jav a 2 s.c o m*/ gc.set(GregorianCalendar.YEAR, 2003); gc.set(GregorianCalendar.MONTH, 12); gc.set(GregorianCalendar.DATE, 1); int m = gc.get(GregorianCalendar.MONTH) + 1; int d = gc.get(GregorianCalendar.DATE); String mm = Integer.toString(m); String dd = Integer.toString(d); System.out.println(gc.get(GregorianCalendar.YEAR) + (m < 10 ? "0" + mm : mm) + (d < 10 ? "0" + dd : dd)); }
From source file:MainClass.java
public static void main(String[] a) { GregorianCalendar calendar = new GregorianCalendar(); calendar.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); calendar.add(Calendar.YEAR, -14); System.out.println(calendar.get(Calendar.YEAR)); }
From source file:MainClass.java
public static void main(String[] a) { GregorianCalendar calendar = new GregorianCalendar(); calendar.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); calendar.add(Calendar.YEAR, 14); // 14 years into the future System.out.println(calendar.get(Calendar.YEAR)); }
From source file:MainClass.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); System.out.println(day);/*from ww w . ja v a2s . c o m*/ }
From source file:Main.java
public static void main(String[] a) { GregorianCalendar today = new GregorianCalendar(); GregorianCalendar thisDate = new GregorianCalendar(); thisDate.set(Calendar.YEAR, 2000); if (thisDate.before(today)) { System.out.println("before"); }/*from w w w .jav a2s . com*/ if (today.after(thisDate)) { System.out.println("after"); } }