List of usage examples for java.text SimpleDateFormat format
public final String format(Date date)
From source file:Main.java
public static String getNowTime(String matchStr) { Date currentTime = new Date(); SimpleDateFormat formatter = new SimpleDateFormat(matchStr); String dateString = formatter.format(currentTime); return dateString; }
From source file:Main.java
public static String getShortMonthStringOnlyFromDate(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);//from w w w . j ava 2s . c om SimpleDateFormat format = new SimpleDateFormat("MMM", Locale.US); return format.format(date); }
From source file:Main.java
public static String getDate() { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); String str = sdf.format(date); return str;// www . ja v a 2 s.c o m }
From source file:Main.java
public static String longToString(Long longTime, String pattern) { SimpleDateFormat df = new SimpleDateFormat(pattern); try {/*www . j av a 2 s .c o m*/ return df.format(longTime); } catch (Exception e) { return ""; } }
From source file:Main.java
@SuppressLint("SimpleDateFormat") public static String getPhotoFileName() { Date date = new Date(System.currentTimeMillis()); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss"); return dateFormat.format(date) + ".jpg"; }
From source file:Main.java
public static String date2string(Date date, String format) { if (date == null) { return ""; }//from w ww . java2 s . co m SimpleDateFormat sdf = new SimpleDateFormat(format); String result = sdf.format(date); sdf = null; return result; }
From source file:Main.java
public static String getTodayDateString() { SimpleDateFormat formatter = new SimpleDateFormat("MM-dd-yyyy"); String dateString = formatter.format(new Date()); return dateString; }
From source file:Main.java
public static String getTimeString(Calendar time) { SimpleDateFormat format = new SimpleDateFormat("h:mm a", Locale.getDefault()); return format.format(time.getTime()); }
From source file:Main.java
public static String formatDate(Date time) { SimpleDateFormat formatter = new SimpleDateFormat("EEE, d MMM yyyy HH:mm Z"); return formatter.format(time); }
From source file:Main.java
public static String getTimeNow() { Calendar cal = Calendar.getInstance(); SimpleDateFormat format = new SimpleDateFormat("HH:ss"); return format.format(cal.getTime()); }