Java Date Format convertDateToGMTDateString(Date date)

Here you can find the source of convertDateToGMTDateString(Date date)

Description

convert Date To GMT Date String

License

Open Source License

Parameter

Parameter Description
date a parameter

Declaration

public static String convertDateToGMTDateString(Date date) 

Method Source Code


//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;
    }
}

Related

  1. convertDateToBulgarianFormat(Date date)
  2. convertDateToCustomFormat(Date date, String datePattern)
  3. convertDateToDateString(Date date)
  4. convertDateToFileName(final Date datum)
  5. convertDateToHour(Date d)
  6. convertDateToISO8601(Date date)
  7. convertDateToMMDDYYYY(Date date)
  8. convertDateToRpcFormat(Date date)