Java Time in GMT getGMTDatetime(Date datetime)

Here you can find the source of getGMTDatetime(Date datetime)

Description

get GMT Datetime

License

Apache License

Declaration

public static String getGMTDatetime(Date datetime) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class Main {
    private static final ThreadLocal<SimpleDateFormat> RFC_822_DATE_FORMAT = new ThreadLocal<SimpleDateFormat>() {
        @Override/*from  ww w. j a v  a 2  s. c  o  m*/
        protected SimpleDateFormat initialValue() {
            SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
            format.setTimeZone(TimeZone.getTimeZone("GMT"));
            return format;
        }
    };

    public static String getGMTDatetime(Date datetime) {
        return RFC_822_DATE_FORMAT.get().format(datetime);
    }
}

Related

  1. getGMTCalendarAtTime(String sTime)
  2. getGMTDate()
  3. getGMTDateFormat(String format)
  4. getGMTDateFormat(String strFormat)
  5. getGMTDateString(Date date)
  6. getGMTDatetimeFormat()
  7. getGmtFromTimeInMillis(String val)
  8. getGMTime()
  9. getGMTime()