List of usage examples for java.util GregorianCalendar set
public void set(int field, int value)
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.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);/* ww w. j av a 2s . c om*/ }
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 cal = new GregorianCalendar(); cal.set(Calendar.ERA, GregorianCalendar.AD); System.out.println(cal.getTime()); }
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 .ja v a2 s .com if (today.after(thisDate)) { System.out.println("after"); } }
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 w w . j a va 2 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 { GregorianCalendar gc = new GregorianCalendar(); gc.setLenient(false);/* w w w . j a v a 2s. c om*/ gc.set(GregorianCalendar.YEAR, 2003); gc.set(GregorianCalendar.MONTH, 12); gc.set(GregorianCalendar.DATE, 1); gc.getTime(); }
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 2s . c om*/ 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)); }