Java Date Long Format getLongGmtDateString(Date date)

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

Description

Converts a Date to the GMT timezone and formats it to the format yyyy-MM-dd HH:mm:ssZ.

License

Open Source License

Parameter

Parameter Description
date the Date to parse.

Return

A formatted date string.

Declaration

public static String getLongGmtDateString(Date date) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.TimeZone;

public class Main {
    /**// w w w . j  ava2  s. c o  m
     * Converts a Date to the GMT timezone and formats it to the format yyyy-MM-dd HH:mm:ssZ.
     *
     * @param date the Date to parse.
     * @return A formatted date string.
     */
    public static String getLongGmtDateString(Date date) {
        if (date == null) {
            return null;
        }

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
                "yyyy-MM-dd'T'HH:mm:ss.SSSZ");
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        return simpleDateFormat.format(date);
    }
}

Related

  1. getLongDateString(Date date, boolean includeTime)
  2. getLongDisplayDate(Date moment, TimeZone tz, Locale inLocale)
  3. getLongDisplayTime(long time)
  4. getLongFormatTime(java.util.Date date)
  5. getLongFromDatestamp(String datestamp)
  6. getLongMillis(String date)
  7. getLongNowTime()
  8. getLongOracleDateTime(Date date)
  9. getLongPattern(final Locale locale)