List of utility methods to do UTC Date
String | getUtcTimestamp() get Utc Timestamp DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); format.setTimeZone(TimeZone.getTimeZone("GMT")); return format.format(new Date()); |
String | getUtcTimestamp() Request timestamp in ISO 8601 combined date and time in UTC. SimpleDateFormat timeFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); timeFormatter.setTimeZone(new SimpleTimeZone(SimpleTimeZone.UTC_TIME, "UTC")); return timeFormatter.format(new Date()); |
String | getUTCTimestamp(Date date) get UTC Timestamp return TS_FORMAT.format(date);
|
String | getUtcTimestampAsString(Date date) Returns an ISO 8601 timestamp for the given date. DateFormat dfm = new SimpleDateFormat(DATE_FORMAT); dfm.setTimeZone(TimeZone.getTimeZone(UTC_TIMEZONE)); return dfm.format(date); |
String | getUTCTimeString4Digits(Date date) get UTC Time String Digits SimpleDateFormat sdf = new SimpleDateFormat("HHmm"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); return sdf.format(date); |
String | nowInUTC() Get the current time in UTC Date date = new Date(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); df.setTimeZone(TimeZone.getTimeZone("GMT")); return df.format(date); |
String | nowUtc(String pattern) Returns the current system date as string with the specified format final SimpleDateFormat dateFormat = new SimpleDateFormat(pattern); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); return dateFormat.format(now()); |
String | nowUTCString() now UTC String try { DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); return formatter.format(nowUTC()); } catch (Exception e) { return null; |
String | SerializeUtc(Date dt) Serialize Utc Calendar c = new GregorianCalendar(UTC, Locale.US); c.setTime(dt); StringBuilder b = new StringBuilder(21); b.append(pad0s(c.get(Calendar.YEAR), 4)); b.append("-"); b.append(pad0s(c.get(Calendar.MONTH) + 1, 2)); b.append("-"); b.append(pad0s(c.get(Calendar.DAY_OF_MONTH), 2)); ... |
Date | stringToUTC(String utc) Converts a UTC date/time string to a UTC date/time value. return ISO_8601_FORMAT.parse(utc);
|