List of utility methods to do Date UTC Format
DateFormat | createUTCDateFormatter(String dateFormat) Creates a DateFormat that assumes the incoming date is in UTC time. DateFormat formatter = new SimpleDateFormat(dateFormat); formatter.setTimeZone(TimeZone.getTimeZone("UTC")); return formatter; |
String | FormatAsUtc(Date date) Format As Utc SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); f.setTimeZone(TimeZone.getTimeZone("UTC")); return f.format(date); |
String | formatAsUTC(java.util.Date date, String pattern) format: returns the formatted date as String. if (date != null) { SimpleDateFormat sdf = new SimpleDateFormat(pattern); sdf.setTimeZone(getUTCTimeZone()); return sdf.format(date); } else { return null; |
String | formatDate(Date date, String pattern, boolean toUTC) Format date to string using specified pattern. DateFormat df = new SimpleDateFormat(pattern); if (toUTC) { TimeZone tz = TimeZone.getTimeZone("UTC"); df.setTimeZone(tz); return df.format(date); |
String | formatTimeStamp(byte[] btValue, int iOffset, int iLength, int iUtcOffset) format Time Stamp if ((btValue.length < iOffset + iLength) || (iLength < 9)) return ""; Date dtReturn = null; long lOffset = 0; if (btValue[iOffset + 2] == '+' || btValue[iOffset + 2] == '-') { dtReturn = new Date(getBCDValue(btValue[iOffset + 8]), getBCDValue(btValue[iOffset + 7]) - 1, getBCDValue(btValue[iOffset + 6]), getBCDValue(btValue[iOffset + 5]), getBCDValue(btValue[iOffset + 4]), getBCDValue(btValue[iOffset + 3])); ... |
String | formatUTC(Date date, String format) format UTC SimpleDateFormat sdf = new SimpleDateFormat(format); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); return sdf.format(date); |
String | formatUtcDateIfNotNull(final Date date) format Utc Date If Not Null if (null == date) { return null; final SimpleDateFormat dateFormat = new SimpleDateFormat(ISO8601_DATE_FORMAT_PATTERN); dateFormat.setTimeZone(TimeZone.getTimeZone(UTC)); String formattedDate; formattedDate = dateFormat.format(date); return formattedDate; ... |
String | formatUtcTime(long tval) format Utc Time SimpleDateFormat utcSdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); utcSdf.setTimeZone(new SimpleTimeZone(0, "UTC")); String stg = utcSdf.format(tval); return stg; |
String | getStrTimeByUTC(long utc, String format) get Str Time By UTC return new SimpleDateFormat(format).format(new Date(utc)); |
SimpleDateFormat | getUTCDateFormat() get UTC Date Format SimpleDateFormat iso8601DateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); iso8601DateFormat.setTimeZone(TimeZone.getTimeZone(UTC_STR)); return iso8601DateFormat; |