From 5ab00e275b539136f48c62b2363936e92d4272c0 Mon Sep 17 00:00:00 2001 From: Bryce McKinlay Date: Wed, 22 Sep 1999 04:41:26 +0000 Subject: [PATCH] MessageFormat.java (MessageFormat(String)): Set the default locale. 1999-09-16 Bryce McKinlay * java/text/MessageFormat.java (MessageFormat(String)): Set the default locale. * java/text/NumberFormat.java: Check that object is a Number. If not, throw IllegialArgumentException. From-SVN: r29574 --- libjava/ChangeLog | 6 ++++++ libjava/java/text/MessageFormat.java | 1 + libjava/java/text/NumberFormat.java | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index f054dbe..703d194 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,9 @@ +1999-09-16 Bryce McKinlay + * java/text/MessageFormat.java (MessageFormat(String)): Set the + default locale. + * java/text/NumberFormat.java: Check that object is a Number. If + not, throw IllegialArgumentException. + 1999-09-21 Tom Tromey * gnu/gcj/convert/Output_UTF8.java (write): Don't exit loop unless diff --git a/libjava/java/text/MessageFormat.java b/libjava/java/text/MessageFormat.java index 8b42235..891a0c3 100644 --- a/libjava/java/text/MessageFormat.java +++ b/libjava/java/text/MessageFormat.java @@ -400,6 +400,7 @@ public class MessageFormat extends Format public MessageFormat (String pattern) { + locale = Locale.getDefault(); applyPattern (pattern); } diff --git a/libjava/java/text/NumberFormat.java b/libjava/java/text/NumberFormat.java index 6ee79b3..a3f7f95 100644 --- a/libjava/java/text/NumberFormat.java +++ b/libjava/java/text/NumberFormat.java @@ -37,7 +37,11 @@ public abstract class NumberFormat extends Format implements Cloneable public final StringBuffer format (Object obj, StringBuffer sbuf, FieldPosition pos) { - return format(((Number) obj).doubleValue(), sbuf, pos); + if (obj instanceof Number) + return format(((Number) obj).doubleValue(), sbuf, pos); + else + throw new IllegalArgumentException + ("Cannot format given Object as a Number"); } public abstract StringBuffer format (double number, -- 2.7.4