List of utility methods to do Date Format As
String | formatDateToDefault(Date date) Format a date for display to a user, in the default time zone. DateFormat format = new SimpleDateFormat("MMM dd, yyyy hh:mm a", Locale.getDefault()); format.setTimeZone(TimeZone.getDefault()); String rv = format.format(date); return rv; |
String | formatDateToMD(Date date) format Date To MD SimpleDateFormat fmt = new SimpleDateFormat("dd/MM", Locale.CHINA); return fmt.format(date); |
String | formatDateToMinutes(Date date) Method formatDateToMinutes. if (date != null) return new SimpleDateFormat("MM/dd/yyyy hh:mm a").format(date); else return null; |
String | formatDateToUTC(Date date) format Date To UTC DateTime dateTime = new DateTime(date); return utcFormatter.print(dateTime); |
String | formatDateToUTC(final Date date) format Date To UTC DateFormat simpleDateFormat = new SimpleDateFormat(DATE_UTC_FORMAT, Locale.US); return simpleDateFormat.format(date) + "Z"; |
String | formatDateUsingW3C(Date date) Use to produce date Strings in the W3C date format String w3cDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(date); return w3cDate = w3cDate.substring(0, 22) + ":" + w3cDate.substring(22, 24); |
String | formatDateUTC(Date d) format Date UTC return (d != null) ? getISO8601DateFormat().format(d) : "NULL"; |
String | formatDateUTC(Date date) format Date UTC return (date != null) ? getDateFormat().format(date) : null;
|
String | formatDateW3C(Date date) format Date WC DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); String text = df.format(date); return text.substring(0, 22) + ":" + text.substring(22); |
String | formatDateWithMilliseconds(DateFormat aFormat, Date aDate) Performs date formatting using the provided format, but injects millisecond precision if the millisecond value is not "000". DateFormat tempFormat = aFormat; if (aDate.getTime() % 1000 != 0) { if (aFormat instanceof SimpleDateFormat) { Field tempField; try { tempField = SimpleDateFormat.class.getDeclaredField("pattern"); tempField.setAccessible(true); String tempPattern = (String) tempField.get(aFormat); ... |