List of utility methods to do Date GMT Format
String | getTimeAndDateAtGMT() This method returns the current time in GMT. String pattern = "MMMMM dd, yyyy; H:mm"; SimpleDateFormat simpleformat = new SimpleDateFormat(pattern); TimeZone tz = TimeZone.getTimeZone("GMT"); java.util.Calendar cal = Calendar.getInstance(tz); simpleformat.setCalendar(cal); String date = simpleformat.format(new Date()); return date + " GMT"; |
String | getTzToGmt(String dateStr, String dateFormat, String beforeTimeZone, String afterTimeZone) get Tz To Gmt SimpleDateFormat sdfBefore = new SimpleDateFormat(dateFormat); sdfBefore.setTimeZone(TimeZone.getTimeZone(beforeTimeZone)); SimpleDateFormat sdfAfter = new SimpleDateFormat(dateFormat); sdfAfter.setTimeZone(TimeZone.getTimeZone(afterTimeZone)); Date date = stringToDate(dateStr, sdfBefore); String dateGmtEight = sdfAfter.format(date); return dateGmtEight; |
Date | parseDate(String gmtTimeString) parse Date try { DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); df.setTimeZone(java.util.TimeZone.getTimeZone("GMT")); Date date = df.parse(gmtTimeString); return date; } catch (ParseException e) { throw new RuntimeException("convrt to runtime exception", e); |
Date | parseGMT(String gmtTime) parse GMT GMT_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT")); return GMT_FORMAT.parse(gmtTime); |
Date | parseGMTDatetime(String str) parse GMT Datetime SimpleDateFormat sdf = getGMTDatetimeFormat();
return sdf.parse(str);
|
String | parseGMTTime(Long time, String format) parse GMT Time Date date = new Date(); date.setTime(time); SimpleDateFormat dformat = getDateParser(format); return dformat.format(date); |
String | timeStampGMT(Date date) Creates a formatted timestamp string of the given date in GMT. return timeStamp(date, GMT);
|
String | toGMTString(Date d) Returns a string representation of the given Date object of the form: d MMM yyyy hh:mm:ss GMT SimpleDateFormat formatter = new SimpleDateFormat("d MMM yyyy HH:mm:ss z", Locale.US); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); return formatter.format(d); |
String | toGMTString(Date dtIn) Convert a date into a format suitable for http headers etc "EEE, dd MMM yyyy HH:mm:ss z" if (dtIn == null) dtIn = new Date(); String sGMTFormat = "EEE, dd MMM yyyy HH:mm:ss z"; return formatDate(dtIn, sGMTFormat, Locale.UK, TimeZone.getTimeZone("GMT")); |
String | toStringWithoutGMT(Date date) to String Without GMT return toStringWithoutGMT(date, null);
|