[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Two methods for NumberFormat
From: |
Guilhem Lavaux |
Subject: |
[PATCH] Two methods for NumberFormat |
Date: |
Fri, 21 Nov 2003 21:34:40 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 |
Hi,
I am continuing the series of patches with that one, it adds two methods
to NumberFormat: getIntegerInstance() and getIntegerInstance(Locale).
They have to be implemented according to Java 1.4.
Please review it before I check it in.
Regards,
Guilhem.
Index: java/text/NumberFormat.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/NumberFormat.java,v
retrieving revision 1.4
diff -u -r1.4 NumberFormat.java
--- java/text/NumberFormat.java 22 Jan 2002 22:27:01 -0000 1.4
+++ java/text/NumberFormat.java 21 Nov 2003 19:58:29 -0000
@@ -323,6 +415,34 @@
public static NumberFormat getNumberInstance (Locale loc)
{
return computeInstance (loc, "numberFormat", "#,##0.###");
+ }
+
+ /**
+ * This method returns an integer formatting and parsing class for the
+ * default locale. This will be a concrete subclass of
<code>NumberFormat</code>,
+ * but the actual class returned is dependent on the locale.
+ *
+ * @return An instance of an integer number formatter for the default locale.
+ */
+ public static final NumberFormat getIntegerInstance()
+ {
+ return getIntegerInstance (Locale.getDefault());
+ }
+
+ /**
+ * This method returns an integer formatting and parsing class for the
+ * default locale. This will be a concrete subclass of
<code>NumberFormat</code>,
+ * but the actual class returned is dependent on the locale.
+ *
+ * @param locale the desired locale.
+ *
+ * @return An instance of an integer number formatter for the default locale.
+ */
+ public static NumberFormat getIntegerInstance(Locale locale)
+ {
+ NumberFormat format = computeInstance (locale, "numberFormat", "#,##0");
+ format.setParseIntegerOnly (true);
+ return format;
}
/**
- [PATCH] Two methods for NumberFormat,
Guilhem Lavaux <=