Here you can find the source of convertDateToGMTDateString(Date date)
Parameter | Description |
---|---|
date | a parameter |
public static String convertDateToGMTDateString(Date date)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { /**// w ww. j a v a2s .co m * @param date * @return */ public static String convertDateToGMTDateString(Date date) { // Convert local date to GMT date String SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z"); TimeZone tz = TimeZone.getTimeZone("GMT"); sdf.setTimeZone(tz); String dateStr = sdf.format(date); return dateStr; } }