List of usage examples for java.util Calendar getTime
public final Date getTime()
Date
object representing this Calendar
's time value (millisecond offset from the Epoch"). From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); // return a string representation of this calendar. System.out.println(cal.getTime().toString()); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); // print current time System.out.println("Current year is :" + cal.getTime()); // set the year,month and day to something else cal.set(2013, 5, 25, 04, 15, 20);/*w ww.ja v a 2 s . c om*/ System.out.println("Altered year is :" + cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); // print current time System.out.println("Current year is :" + cal.getTime()); // set the year,month and day to something else cal.set(2013, 5, 25, 04, 15);/*w w w . ja v a 2 s .c o m*/ // print the result System.out.println("Altered year is :" + cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); // print current time System.out.println("Current year is :" + cal.getTime()); // set the year,month and day to something else cal.set(2013, 5, 25);//ww w .ja va2s. c om // print the result System.out.println("Altered year is :" + cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); // get the current time System.out.println("Current time is :" + cal.getTime()); Date date = new Date(); cal.setTime(date);//w w w.j a v a2s . co m // print the new time System.out.println("After setting Time: " + cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { Calendar now = Calendar.getInstance(); System.out.println(now.getTime()); int month = now.get(Calendar.MONTH); if (month == Calendar.JANUARY) { System.out.println("JANUARY"); }//from w ww . jav a2s .c o m if (month == Calendar.FEBRUARY) { System.out.println("FEBRUARY"); } if (month == Calendar.MARCH) { System.out.println("MARCH"); } if (month == Calendar.APRIL) { System.out.println("APRIL"); } if (month == Calendar.MAY) { System.out.println("MAY"); } if (month == Calendar.JUNE) { System.out.println("JUNE"); } if (month == Calendar.JULY) { System.out.println("JULY"); } if (month == Calendar.AUGUST) { System.out.println("AUGUST"); } if (month == Calendar.SEPTEMBER) { System.out.println("SEPTEMBER"); } if (month == Calendar.OCTOBER) { System.out.println("OCTOBER"); } if (month == Calendar.NOVEMBER) { System.out.println("NOVEMBER"); } if (month == Calendar.DECEMBER) { System.out.println("DECEMBER"); } }
From source file:Main.java
public static void main(String[] args) { Date d1 = new Date(); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, 22);//from w ww .j ava2 s .co m Date d2 = cal.getTime(); Iterator<Date> i = new DateIterator(d1, d2); while (i.hasNext()) { Date date = i.next(); System.out.println(date); } }
From source file:Main.java
public static void main(String[] args) throws ParseException { SimpleDateFormat dateFormat = new SimpleDateFormat("ddMMyyyy"); Calendar cal = Calendar.getInstance(); String today = dateFormat.format(cal.getTime()); System.out.println(today);/* w w w. j a v a 2 s . co m*/ SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy"); Date actualdate = sdf.parse(today); Date date1 = sdf.parse("20042014"); Date date2 = sdf.parse("23042015"); Calendar actual = Calendar.getInstance(); Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); actual.setTime(actualdate); cal1.setTime(date1); cal2.setTime(date2); System.out.println(actual); System.out.println(cal1); System.out.println(cal2); if (actualdate.after(date1) && actualdate.before(date2)) { System.out.println("Yes"); } else { System.out.println("No"); } if (actual.after(cal1) && actual.before(cal2)) { System.out.println("Yes"); } else { System.out.println("No"); } }
From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); // get the time in milliseconds System.out.println("Current time is :" + cal.getTime()); // set time to 5000000000 ms after january 1 1970 cal.setTimeInMillis(5000000000L);//from ww w . jav a 2 s.c o m // print the new time System.out.println("After setting Time: " + cal.getTime()); }
From source file:MainClass.java
public static void main(String[] pArgs) throws Exception { Calendar cal = Calendar.getInstance(); cal.set(2004, 2, 5, 10, 2, 2);//from w w w . j a v a 2 s.com System.out.println(DateUtils.round(cal.getTime(), DateUtils.SEMI_MONTH)); }