Java Hour Format format(Date date)

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

Description

format

License

Apache License

Declaration

public static String format(Date date) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.DateFormat;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class Main {
    /**/*from  w  ww  .j  a  v  a  2  s.com*/
     * RFC822 5. DATE AND TIME SPECIFICATION
     */
    static final String RFC1123_DATEFORMAT = "EEE, dd MMM yyyy HH:mm:ss zzz";
    static final TimeZone GMT = TimeZone.getTimeZone("GMT");

    public static String format(Date date) {
        DateFormat fmt = newGMTFormatter();
        return fmt.format(date);
    }

    public static DateFormat newGMTFormatter() {
        SimpleDateFormat fmt = new SimpleDateFormat(RFC1123_DATEFORMAT, Locale.ENGLISH);
        fmt.setTimeZone(GMT);
        return fmt;
    }
}

Related

  1. format(Date date)
  2. format(Date date)
  3. format(Date date)
  4. format(Date date)
  5. format(Date date)
  6. format(Date date)
  7. format(Date date)
  8. format(Date date)
  9. format(Date date)