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 time() { SimpleDateFormat format = new SimpleDateFormat("hh:mm:ss"); Calendar c = Calendar.getInstance(); String date = format.format(c.getTime()); return date;/*from w ww. j av a 2 s .com*/ }
From source file:Main.java
public static String date() { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); Calendar c = Calendar.getInstance(); String date = format.format(c.getTime()); return date;/* w w w .ja v a2 s. c om*/ }
From source file:Main.java
public static String getCurrentDate() { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Calendar cal = Calendar.getInstance(); return dateFormat.format(cal.getTime()); }
From source file:Main.java
public static Date addSeconds(Date date, Integer seconds) { Calendar cal = Calendar.getInstance(); cal.setTime(date);//from w ww . ja v a 2 s .c o m cal.add(Calendar.SECOND, seconds); return cal.getTime(); }
From source file:Main.java
public static Date addDays(Date date, Integer days) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/* ww w . j a v a 2s. co m*/ cal.add(Calendar.DAY_OF_MONTH, days); return cal.getTime(); }
From source file:Main.java
public static String getDateTimeString(long time) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(time);//from w w w . j a v a 2 s . c om return c.getTime().toString(); }
From source file:Main.java
public static Date getLastWeekTime() { Calendar c = Calendar.getInstance(); c.add(Calendar.DATE, -6);/* w w w. j ava2s .c o m*/ return c.getTime(); }
From source file:Main.java
public static String getCurrentDate() { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); Calendar currentDate = Calendar.getInstance(); return dateFormat.format(currentDate.getTime()); }
From source file:Main.java
public static String getCurrentDate() { DateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd"); Calendar cal = Calendar.getInstance(); String currentDate = dateFormat.format(cal.getTime()); return currentDate; }
From source file:Main.java
public static Date getYesterday() { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -1);/*from w w w .j a v a2s . co m*/ return cal.getTime(); }