List of usage examples for java.text SimpleDateFormat format
public final String format(Date date)
From source file:Main.java
public static String getDateFromDateTime(Timestamp dateTime) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); return sdf.format(dateTime).toString(); }
From source file:Main.java
public static String dateToString(Date date) { SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT); return df.format(date); }
From source file:Main.java
public static String dateformat(String format, Date date, int afterDay) { Calendar ca = Calendar.getInstance(); ca.setTime(date);// w w w.j av a 2 s . c o m if (afterDay != 0) ca.add(Calendar.DATE, afterDay); SimpleDateFormat df = new SimpleDateFormat(format); return df.format(ca.getTime()); }
From source file:Main.java
public static String getTimeFromDate(Date actualDate) { SimpleDateFormat format = new SimpleDateFormat("HH:00"); return format.format(actualDate); }
From source file:Main.java
public static String dateCastDay(Date d) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); return sdf.format(d); }
From source file:Main.java
public static String getMonthNameFromSeconds(long secs) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(secs * 1000L);/*from ww w .j a va2 s.com*/ SimpleDateFormat format1 = new SimpleDateFormat("MMMM"); return format1.format(c.getTime()); }
From source file:Main.java
public static String getDateFormatString(Date date) { SimpleDateFormat fdm = new SimpleDateFormat("yyyy-MM-dd"); return fdm.format(date); }
From source file:Main.java
public static String formatSystemTime() { SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss"); return format.format(new Date()); }
From source file:Main.java
public static String getCurTime(String format) { long now = System.currentTimeMillis(); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(now);/*from ww w. j a v a2 s.c o m*/ SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(calendar.getTime()); }
From source file:Main.java
public static String getTime(Date date) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); return format.format(date); }