Java Utililty Methods Time in GMT

List of utility methods to do Time in GMT

Description

The list of methods to do Time in GMT are organized into topic(s).

Method

StringgetGMT(Date date)
get GMT
FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
String dateString = FORMAT.format(date);
return dateString;
DategetGMT8Time()
get GMT Time
Date gmt8 = null;
try {
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+8"), Locale.CHINESE);
    Calendar day = Calendar.getInstance();
    day.set(Calendar.YEAR, cal.get(Calendar.YEAR));
    day.set(Calendar.MONTH, cal.get(Calendar.MONTH));
    day.set(Calendar.DATE, cal.get(Calendar.DATE));
    day.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY));
...
StringgetGMTByDisplay(String tm)
get special time zone offset
String gmt = null;
if (null == tm || "Default".equals(tm)) {
    return getDefaultID2GMT();
for (Entry<String, StringBuffer> en : normtoIDsMap.entrySet()) {
    String enKey = en.getValue().toString();
    if (enKey.indexOf(tm) >= 0 || enKey.equalsIgnoreCase(tm)) {
        gmt = en.getKey();
...
CalendargetGMTCalendarAtTime(String sTime)
Gets the calendar at given time at GMT
SimpleDateFormat dtFormat = new SimpleDateFormat(m_sDtFormat);
Calendar newDate = getGMTCalendar();
newDate.setTime(dtFormat.parse(sTime));
return newDate;
StringgetGMTDate()
get GMT Date
SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss 'GMT'", Locale.US);
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
return sdf.format(new Date());
SimpleDateFormatgetGMTDateFormat(String format)
get GMT Date Format
SimpleDateFormat df = new SimpleDateFormat(format);
df.setTimeZone(TimeZone.getTimeZone("GMT"));
return df;
SimpleDateFormatgetGMTDateFormat(String strFormat)
get GMT Date Format
SimpleDateFormat format = new SimpleDateFormat(strFormat);
format.setCalendar(getGMTCalendar());
return format;
StringgetGMTDateString(Date date)
get GMT Date String
SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateInstance();
TimeZone gmt = TimeZone.getTimeZone("GMT");
formatter.setTimeZone(gmt);
formatter.applyPattern("dd MMMM");
String dayString = formatter.format(date);
formatter = (SimpleDateFormat) DateFormat.getTimeInstance();
formatter.setTimeZone(gmt);
formatter.applyPattern("hh:mm zzz yyyy");
...
StringgetGMTDatetime(Date datetime)
get GMT Datetime
return RFC_822_DATE_FORMAT.get().format(datetime);
SimpleDateFormatgetGMTDatetimeFormat()
get GMT Datetime Format
return new SimpleDateFormat(GMT_DATETIME_FORMAT_PATTERN);