Here you can find the source of getGMTDatetime(Date datetime)
public static String getGMTDatetime(Date datetime)
//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); } }