List of usage examples for java.text DateFormat format
public final String format(Date date)
From source file:Main.java
public static String timestamp() { String timestamp = null;//from w w w. ja v a 2 s . c om Calendar cal = Calendar.getInstance(); DateFormat dfm = new SimpleDateFormat("yyyy-MM-ddHH:mm:ss", Locale.US); dfm.setTimeZone(TimeZone.getTimeZone("GMT")); timestamp = dfm.format(cal.getTime()); return timestamp; }
From source file:Main.java
public static String getMonthDay(Date date) { DateFormat df = new SimpleDateFormat(monthDayString, Locale.UK); df.setTimeZone(TimeZone.getTimeZone("UTC")); return df.format(date); }
From source file:Main.java
public static String dateParse(long timeStampInMilliSeconds) { DateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm", Locale.getDefault()); Date d = new Date(timeStampInMilliSeconds); return df.format(d); }
From source file:Main.java
public static String unixTimeStampToDateTime(double unixTimeStamp) { DateFormat dateFormat = new SimpleDateFormat("HH.mm"); Date date = new Date(); date.setTime((long) unixTimeStamp * 1000); return dateFormat.format(date); }
From source file:Main.java
public static String getCurrentDateTimeForFile() { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HHmmss"); Calendar cal = Calendar.getInstance(); String currentDateTimeForFile = dateFormat.format(cal.getTime()); return currentDateTimeForFile; }
From source file:Main.java
public static String getFormattedDateForReQuery(long timeStampInMilliSeconds) { DateFormat df = new SimpleDateFormat("yyyyy-MM-dd HH:mm:ssZ", Locale.getDefault()); Date d = new Date(timeStampInMilliSeconds); return df.format(d); }
From source file:Main.java
public static String toSimpleDateTime(Date date) { DateFormat df = new SimpleDateFormat(simpleDateString, Locale.UK); df.setTimeZone(TimeZone.getTimeZone("UTC")); return df.format(date); }
From source file:Main.java
public static String getCurrentMonthFirstDay(long time) { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM", Locale.CHINA); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(dateFormat.format(time)); stringBuilder.append("-"); stringBuilder.append(1);/*ww w . j av a2 s . co m*/ return stringBuilder.toString(); }
From source file:Main.java
/** * Get the data from milliseconds/* w ww. j ava 2 s . com*/ * * @return {@link String} */ public static String GetDateFromMilliseconds() { DateFormat formatter = new SimpleDateFormat("dd MMM yyyy"); Calendar calendar = Calendar.getInstance(); return formatter.format(calendar.getTime()); }
From source file:com.omnigon.aem.handlebars.helpers.MomentHelper.java
public static String format(String pattern, Date date) { if (StringUtils.isBlank(pattern) || date == null) { return StringUtils.EMPTY; }/*from w ww . j av a 2 s. co m*/ DateFormat dateFormat = new SimpleDateFormat(pattern); return dateFormat.format(date); }