Here you can find the source of rfc2822(Date date)
public static String rfc2822(Date date)
//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); } }