List of utility methods to do Date Format
String | getFormatTime(Date date) get Format Time return getFormatDateTime(date, "yyyy-MM-dd HH:mm:ss"); |
String | getFormatTomorrow(String format) get Format Tomorrow return getFormatCurrentAdd(1, format);
|
String | getFormatYestoday(String format) get Format Yestoday return getFormatCurrentAdd(-1, format);
|
String | getUniversalDateStamp(Date date) Get current time stamp in universal format Format: yyyy-mm-ddThh:mm:ssZ e.g.: 1999-09-09T13:10:40Z Calendar cal = Calendar.getInstance();
cal.setTime(date);
return getUniversalDateStamp(cal);
|
String | getUtcTimeStringFromDate(Date date) Retrieves UTC time as string. SimpleDateFormat dateFormat = new SimpleDateFormat("HH':'mm':'ss"); dateFormat.setTimeZone(TimeZone.getTimeZone("gmt")); return dateFormat.format(date); |
String | timestampToISO8601(Date aDate) timestamp To ISO SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssZ"); return format.format(aDate); |
String | toDateString(Date value) to Date String if (value != null) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return dateFormat.format(value); } else { return ""; |
String | toDateTimeString(Date value) to Date Time String if (value != null) { SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return dateFormat.format(value); } else { return ""; |
String | toRelativeDateString(Date value) to Relative Date String if (value != null) { String result = ""; Date dateNow = new Date(); if ((dateNow.getYear() == value.getYear()) && (dateNow.getMonth() == value.getMonth())) { int daysApart = dateNow.getDate() - value.getDate(); if (daysApart >= 28) { result = "4 weeks ago"; ... |
String | toString(Date date, String format) to String SimpleDateFormat outputFormat = new SimpleDateFormat(format); return outputFormat.format(date); |