List of utility methods to do UTC Date
String | getUTCDate() get UTC Date SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy hh:mm"); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); return sdf.format(cal.getTime()); |
String | getUtcDate(String date, String pattern) get Utc Date try { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date now = Calendar.getInstance().getTime(); Date theDate = format.parse(date); theDate.setHours(now.getHours()); theDate.setMinutes(now.getMinutes()); format.setTimeZone(TimeZone.getTimeZone("UTC")); format.applyPattern(pattern); ... |
Date | getUTCDateFromString(String date) get UTC Date From String DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss", Locale.ENGLISH); Date result = df.parse(date); return getUTCDate(result.getTime()); |
String | getUtcDateString() get Utc Date String Date curDate = new Date(); SimpleDateFormat format = new SimpleDateFormat(UTC_DATE_FORMAT); return format.format(curDate); |
String | getUtcDateStringFromTimestamp(Date timeStamp) Convert timestamp to UTC format date string. DateFormat df = new SimpleDateFormat(UTC_DATE_FORMAT); df.setTimeZone(TimeZone.getTimeZone("GMT")); return df.format(timeStamp); |
String | GetUTCdatetimeAsString() Get UT Cdatetime As String String DATEFORMAT = "yyyy-MM-dd HH:mm:ss"; final SimpleDateFormat sdf = new SimpleDateFormat(DATEFORMAT); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); final String utcTime = sdf.format(new Date()); return utcTime; |
String | GetUtcNow() Get Utc Now return FormatAsUtc(new Date()); |
String | getUTCTime() get UTC Time SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.MONTH_FIELD, DateFormat.LONG, Locale.US); formatter.setTimeZone(TimeZone.getTimeZone(TIME_ZONE_GMT)); formatter.applyPattern(EEE_DD_MMM_YYYY_HH_MM_SS_Z_FORMAT); return formatter.format(new Date()); |
String | getUTCTime() Returns current time in UTC timezone as string Date currentTime = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("EEE, MMM d, yyyy hh:mm:ss a z"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); return sdf.format(currentTime); |
String | getUTCTime(final Date inDate) Returns the UTC date/time for the specified value using the RFC1123 pattern. final DateFormat rfc1123Format = new SimpleDateFormat(RFC1123_PATTERN, LOCALE_US); rfc1123Format.setTimeZone(UTC_ZONE); return rfc1123Format.format(inDate); |