Java Date RFC Format rfc2822(Date date)

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

Description

rfc

License

Open Source License

Declaration

public static String rfc2822(Date date) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2011 IBM Corporation.//from   w  w  w .j  ava2  s. c o m
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Eclipse Distribution License v. 1.0 which accompanies this distribution. 
 *
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 * and the Eclipse Distribution License is available at 
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * Contributors:
 *
 *    Jim Conallen - initial API and implementation
 *******************************************************************************/

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

public class Main {
    public static String rfc2822(Date date) {
        String pattern = "EEE, dd MMM yyyy HH:mm:ss Z"; //$NON-NLS-1$
        SimpleDateFormat format = new SimpleDateFormat(pattern);
        return format.format(date);
    }

    public static Date rfc2822(String dateStr) throws ParseException {
        String pattern = "EEE, dd MMM yyyy HH:mm:ss Z"; //$NON-NLS-1$
        SimpleDateFormat format = new SimpleDateFormat(pattern);
        return format.parse(dateStr);
    }
}

Related

  1. makeDateRFC2822(Date date)
  2. renderDateAsRFC822String(Date date)
  3. resolvedDateRFC822(String pString)
  4. rfc1123Date(Date d)
  5. rfc1123Format(Date date)
  6. rfc822(Date date)
  7. rfc822Date(Date date)
  8. rfc822Date(final Date val)
  9. RFC822Section5Format_to_Date(String time)