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  package org.apache.mailet.dates;
21  
22  import java.util.Date;
23  
24  import javax.mail.internet.MailDateFormat;
25  
26  
27  /***
28   * A thread safe wrapper for the <code>javax.mail.internet.MailDateFormat</code> class.
29   *
30   */
31  public class RFC822DateFormat extends SynchronizedDateFormat {
32      /***
33       * A static instance of the RFC822DateFormat, used by toString
34       */
35      private static RFC822DateFormat instance;
36  
37      static {
38          instance = new RFC822DateFormat();
39      }
40  
41      /***
42       * This static method allows us to format RFC822 dates without
43       * explicitly instantiating an RFC822DateFormat object.
44       *
45       * @return java.lang.String
46       * @param d Date
47       *
48       * @deprecated This method is not necessary and is preserved for API
49       *             backwards compatibility.  Users of this class should
50       *             instantiate an instance and use it as they would any
51       *             other DateFormat object.
52       */
53      public static String toString(Date d) {
54          return instance.format(d);
55      }
56  
57      /***
58       * Constructor for RFC822DateFormat
59       */
60      public RFC822DateFormat() {
61          super(new MailDateFormat());
62      }
63  }