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  package org.apache.myfaces.dateformat;
20  
21  import java.util.Date;
22  import java.util.Locale;
23  
24  /**
25   * A simple class that contains locale-specific constants used for date
26   * parsing and formatting.
27   * <p>
28   * An instance of this can be created, and the symbols modified before
29   * passing it to a SimpleDateFormatter. This allows date formatting and
30   * parsing to be localised.
31   * <p>
32   * The standard Java DateFormatSymbols class could be used directly by
33   * SimpleDateFormatter, making this class unnecessary. However javascript
34   * does not have an equivalent class built-in, so to keep symmetry between
35   * the java and javascript versions we have one here too.
36   * 
37   * @since 1.1.7
38   */
39  public class DateFormatSymbols
40  {
41      String[] eras = {"BC", "AD"};
42  
43      String[] months = {
44              "January", "February", "March", "April",
45              "May", "June", "July", "August", "September", "October",
46              "November", "December", "Undecimber"
47      };
48  
49      String[] shortMonths = {
50              "Jan", "Feb", "Mar", "Apr",
51              "May", "Jun", "Jul", "Aug", "Sep", "Oct",
52              "Nov", "Dec", "Und"
53      };
54  
55      String[] weekdays = {
56              "Sunday", "Monday", "Tuesday",
57              "Wednesday", "Thursday", "Friday", "Saturday"
58      };
59  
60      String[] shortWeekdays = {
61              "Sun", "Mon", "Tue",
62              "Wed", "Thu", "Fri", "Sat"
63      };
64  
65      String[] ampms = { "AM", "PM" };
66  
67      String[] zoneStrings = {
68              null, "long-name", "short-name"
69      };
70  
71      // TODO: move these vars out of this "constant" class.
72      Date threshold;
73      Date twoDigitYearStart;
74  
75  
76      public DateFormatSymbols()
77      {
78          threshold = new Date();
79          threshold.setYear(threshold.getYear()-80);
80          this.twoDigitYearStart = threshold;
81      }
82  
83      public DateFormatSymbols(Locale l)
84      {
85          this();
86  
87          java.text.DateFormatSymbols src = new java.text.DateFormatSymbols(l);
88          this.eras = src.getEras();
89          this.months = src.getMonths();
90          this.shortMonths = src.getShortMonths();
91          this.weekdays = src.getWeekdays();
92          this.shortWeekdays = src.getShortWeekdays();
93          this.ampms = src.getAmPmStrings();
94  
95          // zoneStrings ??
96      }
97  }