View Javadoc

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