List of usage examples for java.text SimpleDateFormat format
public final String format(Date date)
From source file:Main.java
public static String strDate(Long dateMillis) { Date resultdate = new Date(dateMillis); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.US); return df.format(resultdate); }
From source file:Main.java
public static String getTimeStamp() { Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); return sdf.format(cal.getTime()); }
From source file:Main.java
public static String getStringFromDate(Calendar date, String format) { String string;// w w w. j av a2 s. c o m SimpleDateFormat form = new SimpleDateFormat(format, Locale.US); string = form.format(date.getTime()); return string; }
From source file:Main.java
public static String getCurrTime() { Date date = new Date(); SimpleDateFormat fordate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return fordate.format(date); }
From source file:Main.java
public static String formatTime(String date) { if (date == null) { return ""; }//from ww w . ja v a 2 s . com SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(new Date(date)).toString(); }
From source file:Main.java
public static String getTempFileName() { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss_SS"); return format.format(new Timestamp(System.currentTimeMillis())); }
From source file:Main.java
/** * Wrapper for SimpleDateFormat("yyyy-MM-dd HH:mm:ss"). * ie. "2014-05-31 19:59:08"//from ww w. ja va 2 s .com * * @param date * @return "yyyy-MM-dd HH:mm:ss" */ public static String date2str(Date date) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(date); }
From source file:Main.java
public static String getTime(String pattern) { SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, Locale.CHINA); return dateFormat.format(new Date()); }
From source file:Main.java
public static String createName(String format, long dateTaken) { Date date = new Date(dateTaken); SimpleDateFormat dateFormat = new SimpleDateFormat(format); return dateFormat.format(date); }
From source file:Main.java
public static String createCommentTime() { Date now = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); String strNow = sdf.format(now); return strNow; }