Java Date RFC Format rfc1123Date(Date d)

Here you can find the source of rfc1123Date(Date d)

Description

Return the RFC1123 string representation of a date.

License

Apache License

Parameter

Parameter Description
d a parameter

Declaration

public static final String rfc1123Date(Date d) 

Method Source Code

//package com.java2s;
/**/*from   ww w.  j  a  va2  s .c  o  m*/
 * Copyright (C) 2011 University of Washington
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

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

import java.util.TimeZone;

public class Main {
    /**
     * Date format pattern used to parse HTTP date headers in RFC 1123 format.
     * copied from apache.commons.lang.DateUtils
     */
    private static final String PATTERN_RFC1123 = "EEE, dd MMM yyyy HH:mm:ss zzz";

    /**
     * Return the RFC1123 string representation of a date.
     * 
     * @param d
     * @return
     */
    public static final String rfc1123Date(Date d) {
        if (d == null)
            return null;
        // SDF is not thread-safe
        SimpleDateFormat asGMTrfc1123 = new SimpleDateFormat(
                PATTERN_RFC1123); // with
                                  // time
                                  // zone
        asGMTrfc1123.setTimeZone(TimeZone.getTimeZone("GMT"));
        return asGMTrfc1123.format(d);
    }
}

Related

  1. getRfc822DateStringGMT(Date date)
  2. getRFC822String(Date date)
  3. makeDateRFC2822(Date date)
  4. renderDateAsRFC822String(Date date)
  5. resolvedDateRFC822(String pString)
  6. rfc1123Format(Date date)
  7. rfc2822(Date date)
  8. rfc822(Date date)
  9. rfc822Date(Date date)