Return-Path: Delivered-To: apmail-myfaces-commits-archive@www.apache.org Received: (qmail 25695 invoked from network); 20 Dec 2007 13:45:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Dec 2007 13:45:57 -0000 Received: (qmail 71379 invoked by uid 500); 20 Dec 2007 13:45:46 -0000 Delivered-To: apmail-myfaces-commits-archive@myfaces.apache.org Received: (qmail 71287 invoked by uid 500); 20 Dec 2007 13:45:46 -0000 Mailing-List: contact commits-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Development" Delivered-To: mailing list commits@myfaces.apache.org Received: (qmail 71276 invoked by uid 99); 20 Dec 2007 13:45:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Dec 2007 05:45:46 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Dec 2007 13:45:32 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D45E71A983A; Thu, 20 Dec 2007 05:45:36 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r605928 - /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/DateFormatSymbols.java Date: Thu, 20 Dec 2007 13:45:36 -0000 To: commits@myfaces.apache.org From: skitching@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071220134536.D45E71A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: skitching Date: Thu Dec 20 05:45:36 2007 New Revision: 605928 URL: http://svn.apache.org/viewvc?rev=605928&view=rev Log: Add constructor that takes a Locale object. Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/DateFormatSymbols.java Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/DateFormatSymbols.java URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/DateFormatSymbols.java?rev=605928&view=auto ============================================================================== --- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/DateFormatSymbols.java (added) +++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/dateformat/DateFormatSymbols.java Thu Dec 20 05:45:36 2007 @@ -0,0 +1,75 @@ +package org.apache.myfaces.dateformat; + +import java.util.Date; +import java.util.Locale; + +/** + * A simple class that contains locale-specific constants used for date + * parsing and formatting. + *

+ * An instance of this can be created, and the symbols modified before + * passing it to a SimpleDateFormatter. This allows date formatting and + * parsing to be localised. + *

+ * The standard Java DateFormatSymbols class could be used directly by + * SimpleDateFormatter, making this class unnecessary. However javascript + * does not have an equivalent class built-in, so to keep symmetry between + * the java and javascript versions we have one here too. + */ +public class DateFormatSymbols +{ + String[] eras = {"BC", "AD"}; + + String[] months = { + "January", "February", "March", "April", + "May", "June", "July", "August", "September", "October", + "November", "December", "Undecimber" + }; + + String[] shortMonths = { + "Jan", "Feb", "Mar", "Apr", + "May", "Jun", "Jul", "Aug", "Sep", "Oct", + "Nov", "Dec", "Und" + }; + + String[] weekdays = { + "Sunday", "Monday", "Tuesday", + "Wednesday", "Thursday", "Friday", "Saturday" + }; + + String[] shortWeekdays = { + "Sun", "Mon", "Tue", + "Wed", "Thu", "Fri", "Sat" + }; + + String[] ampms = { "AM", "PM" }; + + String[] zoneStrings = { + null, "long-name", "short-name" + }; + + // TODO: move these vars out of this "constant" class. + Date threshold; + Date twoDigitYearStart; + + + public DateFormatSymbols() + { + threshold = new Date(); + threshold.setYear(threshold.getYear()-80); + this.twoDigitYearStart = threshold; + } + + public DateFormatSymbols(Locale l) + { + java.text.DateFormatSymbols src = java.text.DateFormatSymbols.getInstance(l); + this.eras = src.getEras(); + this.months = src.getMonths(); + this.shortMonths = src.getShortMonths(); + this.weekdays = src.getWeekdays(); + this.shortWeekdays = src.getShortWeekdays(); + this.ampms = src.getAmPmStrings(); + + // zoneStrings ?? + } +}