List of usage examples for java.text SimpleDateFormat format
public final String format(Date date)
From source file:Main.java
public static String formatDateTime(Timestamp timestamp, String fmt) { SimpleDateFormat format = new SimpleDateFormat(fmt, Locale.CHINA); return format.format(timestamp); }
From source file:Main.java
public static String setTimeDate(long time) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String timeDate = format.format(new Date(time)); return timeDate; }
From source file:Main.java
public static String getTimeOfDayFromString(String dateString) { java.util.Calendar c = getCalendarFromStringDate(dateString); SimpleDateFormat format = new SimpleDateFormat("HH:mm"); return format.format(c.getTime()); }
From source file:Main.java
public static String getDate(long time, String format) { TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai"); TimeZone.setDefault(tz);//from w w w . java 2s . c o m String datetime = ""; Date date = new Date(time); SimpleDateFormat sdf = new SimpleDateFormat(format); datetime = sdf.format(date); return datetime; }
From source file:Main.java
public static String getCurrentTime() { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd "); String currenttime = df.format(new Date()); return currenttime; }
From source file:Main.java
/*********************************************************************************************** * ...// w ww.ja va 2 s . c o m * ********************************************************************************************/ public static String timeToFormattedString(Date date) { SimpleDateFormat simpleDateFormatDay = new SimpleDateFormat("h:mm aa"); return simpleDateFormatDay.format(date); }
From source file:Main.java
public static String dateToStringAssigRaco(Date date) { SimpleDateFormat sdf = new SimpleDateFormat("dd/MM - hh:mm a"); String sDate = sdf.format(date); return sDate; }
From source file:Main.java
public static String format(Date date, String pattern) { String returnValue = ""; if (date != null) { SimpleDateFormat df = new SimpleDateFormat(pattern); returnValue = df.format(date); }/*from w ww . ja v a 2 s .co m*/ return (returnValue); }
From source file:Main.java
public static String getStringDate() { Date currentTime = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return formatter.format(currentTime); }
From source file:Main.java
public static boolean equalsHour(Date a, Date b) { SimpleDateFormat yearFormat = new SimpleDateFormat("yyyyMMddhh", locale); return yearFormat.format(a).equals(yearFormat.format(b)); }