summaryrefslogtreecommitdiff
path: root/java/text/DateFormatSymbols.java
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-12-29 02:17:57 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-12-29 02:17:57 +0000
commit0532989da389aebcb620ce0925a22d6c1509c3e8 (patch)
treed00177689424a63b77caa73e85169fe964814e71 /java/text/DateFormatSymbols.java
parent7814ce60e0cfcdfa6226f84ba038699f27fdf479 (diff)
downloadclasspath-0532989da389aebcb620ce0925a22d6c1509c3e8.tar.gz
2006-12-29 Andrew John Hughes <gnu_andrew@member.fsf.org>
* java/text/DateFormatSymbols: (DateFormatSymbols()): Update documentation. (DateFormatSymbols(Locale)): Likewise. (getInstance()): Implemented. (getInstance(Locale)): Partially implemented. * java/util/Calendar.java: (SHORT, LONG, ALL_STYLES): New constants. (getDisplayName(int,int,Locale)); Implemented. (getDisplayNames(int,int,Locale)): Likewise.
Diffstat (limited to 'java/text/DateFormatSymbols.java')
-rw-r--r--java/text/DateFormatSymbols.java64
1 files changed, 61 insertions, 3 deletions
diff --git a/java/text/DateFormatSymbols.java b/java/text/DateFormatSymbols.java
index bffd31fb6..8b9c186c3 100644
--- a/java/text/DateFormatSymbols.java
+++ b/java/text/DateFormatSymbols.java
@@ -1,5 +1,5 @@
/* DateFormatSymbols.java -- Format over a range of numbers
- Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,7 +45,9 @@ import java.util.ResourceBundle;
/**
* This class acts as container for locale specific date/time formatting
* information such as the days of the week and the months of the year.
+ *
* @author Per Bothner (bothner@cygnus.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @date October 24, 1998.
*/
/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3.
@@ -114,11 +116,17 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
/**
* This method initializes a new instance of <code>DateFormatSymbols</code>
* by loading the date format information for the specified locale.
+ * This constructor only obtains instances using the runtime's resources;
+ * to also include {@link java.text.spi.DateFormatSymbolsProvider} instances,
+ * call {@link #getInstance(Locale)} instead.
*
* @param locale The locale for which date formatting symbols should
* be loaded.
+ * @throws MissingResourceException if the resources for the specified
+ * locale could not be found or loaded.
*/
- public DateFormatSymbols (Locale locale) throws MissingResourceException
+ public DateFormatSymbols (Locale locale)
+ throws MissingResourceException
{
ResourceBundle res
= ResourceBundle.getBundle("gnu.java.locale.LocaleInformation", locale,
@@ -139,8 +147,12 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
/**
* This method loads the format symbol information for the default
* locale.
+ *
+ * @throws MissingResourceException if the resources for the default
+ * locale could not be found or loaded.
*/
- public DateFormatSymbols () throws MissingResourceException
+ public DateFormatSymbols()
+ throws MissingResourceException
{
this (Locale.getDefault());
}
@@ -537,4 +549,50 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
^ hashCode(weekdays)
^ hashCode(zoneStrings));
}
+
+ /**
+ * Returns a {@link DateFormatSymbols} instance for the
+ * default locale obtained from either the runtime itself
+ * or one of the installed
+ * {@link java.text.spi.DateFormatSymbolsProvider} instances.
+ * This is equivalent to calling
+ * <code>getInstance(Locale.getDefault())</code>.
+ *
+ * @return a {@link DateFormatSymbols} instance for the default
+ * locale.
+ * @since 1.6
+ */
+ public static final DateFormatSymbols getInstance()
+ {
+ return getInstance(Locale.getDefault());
+ }
+
+ /**
+ * Returns a {@link DateFormatSymbols} instance for the
+ * specified locale obtained from either the runtime itself
+ * or one of the installed
+ * {@link java.text.spi.DateFormatSymbolsProvider} instances.
+ *
+ * @param locale the locale for which an instance should be
+ * returned.
+ * @return a {@link DateFormatSymbols} instance for the specified
+ * locale.
+ * @throws NullPointerException if <code>locale</code> is
+ * <code>null</code>.
+ * @since 1.6
+ */
+ public static final DateFormatSymbols getInstance(Locale locale)
+ {
+ try
+ {
+ DateFormatSymbols syms = new DateFormatSymbols(locale);
+ return syms;
+ }
+ catch (MissingResourceException e)
+ {
+ /* FIXME: Check the service provider */
+ return null;
+ }
+ }
+
}