1 /************************************************************************ 2 * Copyright (c) 1999-2006 The Apache Software Foundation. * 3 * All rights reserved. * 4 * ------------------------------------------------------------------- * 5 * Licensed under the Apache License, Version 2.0 (the "License"); you * 6 * may not use this file except in compliance with the License. You * 7 * may obtain a copy of the License at: * 8 * * 9 * http://www.apache.org/licenses/LICENSE-2.0 * 10 * * 11 * Unless required by applicable law or agreed to in writing, software * 12 * distributed under the License is distributed on an "AS IS" BASIS, * 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * 14 * implied. See the License for the specific language governing * 15 * permissions and limitations under the License. * 16 ***********************************************************************/ 17 18 package org.apache.mailet.dates; 19 20 import java.util.Date; 21 22 import javax.mail.internet.MailDateFormat; 23 24 25 /*** 26 * A thread safe wrapper for the <code>javax.mail.internet.MailDateFormat</code> class. 27 * 28 */ 29 public class RFC822DateFormat extends SynchronizedDateFormat { 30 /*** 31 * A static instance of the RFC822DateFormat, used by toString 32 */ 33 private static RFC822DateFormat instance; 34 35 static { 36 instance = new RFC822DateFormat(); 37 } 38 39 /*** 40 * This static method allows us to format RFC822 dates without 41 * explicitly instantiating an RFC822DateFormat object. 42 * 43 * @return java.lang.String 44 * @param d Date 45 * 46 * @deprecated This method is not necessary and is preserved for API 47 * backwards compatibility. Users of this class should 48 * instantiate an instance and use it as they would any 49 * other DateFormat object. 50 */ 51 public static String toString(Date d) { 52 return instance.format(d); 53 } 54 55 /*** 56 * Constructor for RFC822DateFormat 57 */ 58 public RFC822DateFormat() { 59 super(new MailDateFormat()); 60 } 61 }