List of usage examples for java.util GregorianCalendar GregorianCalendar
GregorianCalendar(TimeZone zone, Locale locale, boolean flag)
From source file:Main.java
public static void main(String[] args) { GregorianCalendar cal = new GregorianCalendar(2013, 9, 9); System.out.println(cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = new GregorianCalendar(1999, 1, 1); Calendar now = new GregorianCalendar(); int res = now.get(Calendar.YEAR) - cal.get(Calendar.YEAR); if ((cal.get(Calendar.MONTH) > now.get(Calendar.MONTH)) || (cal.get(Calendar.MONTH) == now.get(Calendar.MONTH) && cal.get(Calendar.DAY_OF_MONTH) > now.get(Calendar.DAY_OF_MONTH))) { res--;/*from www . j a va 2 s . co m*/ } System.out.println(res); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = new GregorianCalendar(2013, 05, 20); System.out.println("Past calendar : " + cal.getTime()); // create a clone of first cal Calendar cal2 = (Calendar) cal.clone(); System.out.println("Cloned calendar : " + cal2.getTime()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Calendar cal = new GregorianCalendar(2000, Calendar.FEBRUARY, 1); int days = cal.getActualMaximum(Calendar.DAY_OF_MONTH); // 29 }
From source file:MainClass.java
public static void main(String[] args) { Calendar calendar = new GregorianCalendar(2000, // year 10, // month 1); // day of month java.sql.Date date = new java.sql.Date(calendar.getTimeInMillis()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Calendar xmas = new GregorianCalendar(1998, Calendar.DECEMBER, 25); int dayOfWeek = xmas.get(Calendar.DAY_OF_WEEK); // 6=Friday Calendar cal = new GregorianCalendar(2003, Calendar.JANUARY, 1); dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); // 4=Wednesday }
From source file:Main.java
public static void main(String[] argv) throws Exception { Calendar xmas = new GregorianCalendar(1998, Calendar.DECEMBER, 25); Date date = xmas.getTime();/*from w ww.j av a 2s. c o m*/ }
From source file:Main.java
public static void main(String[] args) { // create a calendar Calendar cal = new GregorianCalendar(2010, 9, 15); // print the greatest min. for year field int result = cal.getGreatestMinimum(Calendar.YEAR); System.out.println("The minimum is: " + result); }
From source file:Main.java
public static void main(String[] args) { Date date1 = (new GregorianCalendar(2009, Calendar.OCTOBER, 17)).getTime(); System.out.println(new SimpleDateFormat("EEEE").format(date1)); }
From source file:Main.java
public static void main(String[] args) { GregorianCalendar gc = new GregorianCalendar(2010, Calendar.SEPTEMBER, 9); Date birthDate = gc.getTime(); String pattern = "'I was born on the day' dd 'of the month 'MMMM 'in' yyyy"; SimpleDateFormat simpleFormatter = new SimpleDateFormat(pattern); System.out.println(simpleFormatter.format(birthDate)); }