Java Date RFC Format getRfc1123DateFormat()

Here you can find the source of getRfc1123DateFormat()

Description

Creates a new instance of a DateFormat for RFC1123 compliant dates.

License

Open Source License

Return

a new instance

Declaration

public static DateFormat getRfc1123DateFormat() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import java.util.Locale;

import java.util.TimeZone;

public class Main {
    /**//w  ww. j  av  a  2  s .c o  m
     * Creates a new instance of a <code>DateFormat</code> for RFC1123 compliant dates. <br>
     * Should be stored for later use but be aware that this DateFormat is not Thread-safe! <br>
     * If you have to deal with dates in this format with JavaScript, it's easy, because the JavaScript Date object has
     * a constructor for strings formatted this way.
     * 
     * @return a new instance
     */
    public static DateFormat getRfc1123DateFormat() {
        final DateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH);
        format.setLenient(false);
        format.setTimeZone(TimeZone.getTimeZone("UTC"));
        return format;
    }
}

Related

  1. get3339Date(String rfc3339Date)
  2. getRFC1123Date()
  3. getRFC2616Date(Date date)
  4. getRFC3339String(Calendar timestamp)
  5. getRFC822()
  6. getRFC822Date()