Java tutorial
//package com.java2s; /** * Copyright (c) 2012 The Wiseserc. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; public class Main { public static String getGMTDate() { return getGMTDate(new Date()); } public static String getGMTDate(Date date) { if (date == null) { return null; } DateFormat dateFormat = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss 'GMT'", Locale.ENGLISH); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); String dateStr = dateFormat.format(date); return dateStr; } }