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 String getTomorrow() { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, 1);// w w w. j av a 2 s .co m Date date = cal.getTime(); SimpleDateFormat sf = new SimpleDateFormat(DATE_FORMAT); return sf.format(date); }
From source file:Main.java
public static String getNow() { Calendar now = Calendar.getInstance(); String when = WHEN_FORMATTER.format(now.getTime()); return when;//from w w w .j a v a 2 s.co m }
From source file:Main.java
static Calendar toNextWholeMinute(Calendar d) { Calendar c = new GregorianCalendar(); c.setTime(d.getTime()); c.add(Calendar.MINUTE, 1);// w w w. j av a 2s . c om c.set(Calendar.SECOND, 0); return c; }
From source file:Main.java
public static Calendar getDateComparedToCurrent(Calendar current, int daysToAdd) { Calendar cal = Calendar.getInstance(); cal.setTime(current.getTime()); cal.add(Calendar.DATE, daysToAdd); return cal;//from www. j av a2s . c o m }
From source file:Main.java
private static Date get6DaysAgo() { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, -6); return calendar.getTime(); }
From source file:Main.java
static Calendar toNextWholeHour(Calendar d) { Calendar c = new GregorianCalendar(); c.setTime(d.getTime()); c.add(Calendar.HOUR, 1);/* w w w . j av a 2s. c o m*/ c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); return c; }
From source file:Main.java
private static Date get3HoursAgo() { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.HOUR, -3); return calendar.getTime(); }
From source file:Main.java
public static Date addField(Date date, int field, int amount) { Calendar result = getCurrentCalendar(date); result.add(field, amount);/*w w w. j a va2s.c o m*/ return result.getTime(); }
From source file:Main.java
public static String getDateHhmmss() { Calendar cal = Calendar.getInstance(); java.util.Date currentTime = cal.getTime(); SimpleDateFormat formatter = new SimpleDateFormat("HHmmss"); String ndate = formatter.format(currentTime); return ndate; }
From source file:Main.java
public static String getCurrentDateYyyyDotMmDotDD() { Calendar cal = Calendar.getInstance(); java.util.Date currentTime = cal.getTime(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd"); String ndate = formatter.format(currentTime); return ndate; }