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:MainClass.java
public static void main(String[] args) throws ParseException { Calendar currenttime = Calendar.getInstance(); Date sqldate = new Date((currenttime.getTime()).getTime()); }
From source file:Main.java
public static void main(String... args) { SimpleDateFormat df = new SimpleDateFormat("MM/dd/YYYY"); Calendar c = Calendar.getInstance(); System.out.println(df.format(c.getTime())); c.add(Calendar.YEAR, 60);// ww w .ja v a 2 s . c o m System.out.println(df.format(c.getTime())); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); System.out.println("Now : " + cal.getTime()); int monthsToDecrement = -1; cal.add(Calendar.MONTH, monthsToDecrement); System.out.println("Date after decrement: " + cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); System.out.println("Today : " + cal.getTime()); // Subtract 1 year from the calendar cal.add(Calendar.YEAR, -1);//w w w . j a v a2s .com System.out.println("1 year ago: " + cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); System.out.println("Today : " + cal.getTime()); // Substract 1 year from the calendar cal.add(Calendar.YEAR, -1);/*from w w w.ja v a 2 s . c om*/ System.out.println("1 year ago: " + cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); System.out.println("Today : " + cal.getTime()); // Subtract 30 days from the calendar cal.add(Calendar.DATE, -30);/*from w w w .ja v a 2 s . c om*/ System.out.println("30 days ago: " + cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); System.out.println("Today : " + cal.getTime()); // Substract 30 days from the calendar cal.add(Calendar.DATE, -30);/*from www . jav a 2s . c o m*/ System.out.println("30 days ago: " + cal.getTime()); }
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 source file:Main.java
public static void main(String[] args) { Calendar cal = Calendar.getInstance(); System.out.println("Now : " + cal.getTime()); int daysToIncrement = 5; cal.add(Calendar.DATE, daysToIncrement); System.out.println("Date after increment: " + cal.getTime()); }
From source file:MainClass.java
public static void main(String[] pArgs) throws Exception { Date now = new Date(); System.out.println("now: " + DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(now)); Iterator iter = DateUtils.iterator(now, DateUtils.RANGE_WEEK_SUNDAY); while (iter.hasNext()) { Calendar cal = (Calendar) iter.next(); Date cur = cal.getTime(); System.out.println("iterate: " + DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(cur)); }//from w ww . ja v a2 s.co m }