2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 package org.apache.harmony.text.tests.java.text;
19 import dalvik.annotation.KnownFailure;
20 import dalvik.annotation.TestTargets;
21 import dalvik.annotation.TestLevel;
22 import dalvik.annotation.TestTargetNew;
23 import dalvik.annotation.TestTargetClass;
25 import junit.framework.TestCase;
27 import java.text.ChoiceFormat;
28 import java.text.DecimalFormat;
29 import java.text.FieldPosition;
30 import java.text.NumberFormat;
31 import java.text.ParseException;
32 import java.text.ParsePosition;
33 import java.util.Currency;
34 import java.util.Locale;
36 @TestTargetClass(NumberFormat.class)
37 public class NumberFormatTest extends TestCase {
40 * @tests java.text.NumberFormat#format(java.lang.Object,
41 * java.lang.StringBuffer, java.text.FieldPosition)
44 level = TestLevel.COMPLETE,
47 args = {java.lang.Object.class, java.lang.StringBuffer.class, java.text.FieldPosition.class}
49 public void test_formatLjava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition() {
52 DecimalFormat format = (DecimalFormat) NumberFormat
53 .getInstance(Locale.US);
55 pos = new FieldPosition(0);
56 out = format.format(new Long(Long.MAX_VALUE), new StringBuffer(), pos);
57 assertEquals("Wrong result L1: " + out, "9,223,372,036,854,775,807",
60 pos = new FieldPosition(0);
61 out = format.format(new Long(Long.MIN_VALUE), new StringBuffer(), pos);
62 assertEquals("Wrong result L2: " + out, "-9,223,372,036,854,775,808",
65 pos = new FieldPosition(0);
66 out = format.format(new java.math.BigInteger(String
67 .valueOf(Long.MAX_VALUE)), new StringBuffer(), pos);
68 assertEquals("Wrong result BI1: " + out, "9,223,372,036,854,775,807",
71 pos = new FieldPosition(0);
72 out = format.format(new java.math.BigInteger(String
73 .valueOf(Long.MIN_VALUE)), new StringBuffer(), pos);
74 assertEquals("Wrong result BI2: " + out, "-9,223,372,036,854,775,808",
77 java.math.BigInteger big;
78 pos = new FieldPosition(0);
79 big = new java.math.BigInteger(String.valueOf(Long.MAX_VALUE))
80 .add(new java.math.BigInteger("1"));
81 out = format.format(big, new StringBuffer(), pos);
82 assertEquals("Wrong result BI3: " + out, "9,223,372,036,854,775,808",
85 pos = new FieldPosition(0);
86 big = new java.math.BigInteger(String.valueOf(Long.MIN_VALUE))
87 .add(new java.math.BigInteger("-1"));
88 out = format.format(big, new StringBuffer(), pos);
89 assertEquals("Wrong result BI4: " + out, "-9,223,372,036,854,775,809",
92 pos = new FieldPosition(0);
93 out = format.format(new java.math.BigDecimal("51.348"),
94 new StringBuffer(), pos);
95 assertEquals("Wrong result BD1: " + out, "51.348", out.toString());
97 pos = new FieldPosition(0);
98 out = format.format(new java.math.BigDecimal("51"), new StringBuffer(),
100 assertEquals("Wrong result BD2: " + out, "51", out.toString());
105 * @tests java.text.NumberFormat#getIntegerInstance()
108 level = TestLevel.COMPLETE,
110 method = "getIntegerInstance",
113 public void test_getIntegerInstance() throws ParseException {
114 // Test for method java.text.NumberFormat getIntegerInstance()
115 Locale origLocale = Locale.getDefault();
116 Locale.setDefault(Locale.US);
118 DecimalFormat format = (DecimalFormat) NumberFormat
119 .getIntegerInstance();
122 "Test1: NumberFormat.getIntegerInstance().toPattern() returned wrong pattern",
123 "#,##0", format.toPattern());
125 "Test2: NumberFormat.getIntegerInstance().format(35.76) returned wrong value",
126 "36", format.format(35.76));
128 "Test3: NumberFormat.getIntegerInstance().parse(\"35.76\") returned wrong number",
129 new Long(35), format.parse("35.76"));
131 "Test4: NumberFormat.getIntegerInstance().parseObject(\"35.76\") returned wrong number",
132 new Long(35), format.parseObject("35.76"));
133 Locale.setDefault(origLocale);
137 * @tests java.text.NumberFormat#getIntegerInstance(java.util.Locale)
140 level = TestLevel.COMPLETE,
142 method = "getIntegerInstance",
143 args = {java.util.Locale.class}
145 @KnownFailure("Some locales were removed last minute in cupcake")
146 public void test_getIntegerInstanceLjava_util_Locale()
147 throws ParseException {
148 // Test for method java.text.NumberFormat
149 // getIntegerInstance(java.util.Locale)
150 Locale usLocale = Locale.US;
151 // BEGIN android-changed
153 // Locale arLocale = new Locale("ar", "AE");
154 Locale chLocale = new Locale("de", "CH");
155 // END android-changed
157 DecimalFormat format = (DecimalFormat) NumberFormat
158 .getIntegerInstance(usLocale);
160 "Test1: NumberFormat.getIntegerInstance().toPattern() returned wrong pattern",
161 "#,##0", format.toPattern());
163 "Test2: NumberFormat.getIntegerInstance().format(-35.76) returned wrong value",
164 "-36", format.format(-35.76));
166 "Test3: NumberFormat.getIntegerInstance().parse(\"-36\") returned wrong number",
167 new Long(-36), format.parse("-36"));
169 "Test4: NumberFormat.getIntegerInstance().parseObject(\"-36\") returned wrong number",
170 new Long(-36), format.parseObject("-36"));
172 "Test5: NumberFormat.getIntegerInstance().getMaximumFractionDigits() returned wrong value",
173 0, format.getMaximumFractionDigits());
175 "Test6: NumberFormat.getIntegerInstance().isParseIntegerOnly() returned wrong value",
176 format.isParseIntegerOnly());
178 // try with a locale that has a different integer pattern
179 // BEGIN android-changed
181 // format = (DecimalFormat) NumberFormat.getIntegerInstance(arLocale);
182 format = (DecimalFormat) NumberFormat.getIntegerInstance(chLocale);
184 "Test7: NumberFormat.getIntegerInstance(new Locale(\"de\", \"CH\")).toPattern() returned wrong pattern",
185 "#,##0", format.toPattern());
187 "Test8: NumberFormat.getIntegerInstance(new Locale(\"de\", \"CH\")).format(-35.76) returned wrong value",
188 "-36", format.format(-35.76));
190 "Test9: NumberFormat.getIntegerInstance(new Locale(\"de\", \"CH\")).parse(\"-36-\") returned wrong number",
191 new Long(-36), format.parse("-36"));
193 "Test10: NumberFormat.getIntegerInstance(new Locale(\"de\", \"CH\")).parseObject(\"36-\") returned wrong number",
194 new Long(-36), format.parseObject("-36"));
197 "Test11: NumberFormat.getIntegerInstance(new Locale(\"de\", \"CH\")).getMaximumFractionDigits() returned wrong value",
198 0, format.getMaximumFractionDigits());
200 "Test12: NumberFormat.getIntegerInstance(new Locale(\"de\", \"CH\")).isParseIntegerOnly() returned wrong value",
201 format.isParseIntegerOnly());
204 "Test7: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).toPattern() returned wrong pattern",
205 "#,##0;#,##0-", format.toPattern());
207 "Test8: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).format(-35.76) returned wrong value",
208 "36-", format.format(-35.76));
210 "Test9: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).parse(\"-36-\") returned wrong number",
211 new Long(-36), format.parse("36-"));
213 "Test10: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).parseObject(\"36-\") returned wrong number",
214 new Long(-36), format.parseObject("36-"));
217 "Test11: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).getMaximumFractionDigits() returned wrong value",
218 0, format.getMaximumFractionDigits());
220 "Test12: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).isParseIntegerOnly() returned wrong value",
221 format.isParseIntegerOnly());*/
222 // END android-changed
226 * @tests java.text.NumberFormat#getCurrency()
229 level = TestLevel.COMPLETE,
231 method = "getCurrency",
234 public void test_getCurrency() {
235 // Test for method java.util.Currency getCurrency()
237 // a subclass that supports currency formatting
238 Currency currH = Currency.getInstance("HUF");
239 NumberFormat format = NumberFormat.getInstance(new Locale("hu", "HU"));
240 assertSame("Returned incorrect currency", currH, format.getCurrency());
242 // a subclass that doesn't support currency formatting
243 ChoiceFormat cformat = new ChoiceFormat(
244 "0#Less than one|1#one|1<Between one and two|2<Greater than two");
246 ((NumberFormat) cformat).getCurrency();
247 fail("Expected UnsupportedOperationException");
248 } catch (UnsupportedOperationException e) {
253 * @tests java.text.NumberFormat#setMaximumIntegerDigits()
256 level = TestLevel.COMPLETE,
258 method = "setMaximumIntegerDigits",
261 public void test_setMaximumIntegerDigits() {
262 NumberFormat format = NumberFormat.getInstance();
263 format.setMaximumIntegerDigits(2);
264 assertEquals("Wrong result: case 1", "23", format.format(123));
266 format.setMaximumIntegerDigits(Integer.MIN_VALUE);
267 assertEquals("Wrong result: case 2", "0", format.format(123));
271 * @tests java.text.NumberFormat#setCurrency(java.util.Currency)
274 level = TestLevel.COMPLETE,
276 method = "setCurrency",
277 args = {java.util.Currency.class}
279 public void test_setCurrencyLjava_util_Currency() {
280 // Test for method void setCurrency(java.util.Currency)
281 // a subclass that supports currency formatting
282 Currency currA = Currency.getInstance("ARS");
283 NumberFormat format = NumberFormat.getInstance(new Locale("hu", "HU"));
284 format.setCurrency(currA);
285 assertSame("Returned incorrect currency", currA, format.getCurrency());
287 // a subclass that doesn't support currency formatting
288 ChoiceFormat cformat = new ChoiceFormat(
289 "0#Less than one|1#one|1<Between one and two|2<Greater than two");
291 ((NumberFormat) cformat).setCurrency(currA);
292 fail("Expected UnsupportedOperationException");
293 } catch (UnsupportedOperationException e) {
297 NumberFormat.getInstance().setCurrency(null);
298 fail("NullPointerException was thrown.");
299 } catch(NullPointerException npe) {
304 NumberFormat.getIntegerInstance().setCurrency(null);
305 fail("NullPointerException was thrown.");
306 } catch(NullPointerException npe) {
312 * @tests java.text.NumberFormat#parseObject(java.lang.String,
313 * java.text.ParsePosition)
316 level = TestLevel.COMPLETE,
318 method = "parseObject",
319 args = {java.lang.String.class, java.text.ParsePosition.class}
321 @KnownFailure("Some locales were removed last minute in cupcake")
322 public void test_parseObjectLjava_lang_StringLjava_text_ParsePosition() {
323 // regression test for HARMONY-1003
324 assertNull(NumberFormat.getInstance().parseObject("0",
325 new ParsePosition(-1)));
327 parseObjectTest(NumberFormat.getInstance(), "123.123",
328 new ParsePosition(1), new Double(23.123), 7, true);
330 parseObjectTest(NumberFormat.getInstance(), "123.123abc123",
331 new ParsePosition(3), new Double(0.123), 7, true);
333 parseObjectTest(NumberFormat.getInstance(Locale.FRANCE),
335 new ParsePosition(3), new Double(123.123), 10, true);
337 parseObjectTest(NumberFormat.getInstance(Locale.FRANCE),
339 new ParsePosition(0), null, 0, false);
341 parseObjectTest(NumberFormat.getIntegerInstance(),
343 new ParsePosition(3), new Long(123), 6, true);
345 parseObjectTest(NumberFormat.getNumberInstance(),
347 new ParsePosition(1), new Double(-123123.123), 13, true);
348 parseObjectTest(NumberFormat.getNumberInstance(),
350 new ParsePosition(0), null, 0, false);
351 parseObjectTest(NumberFormat.getNumberInstance(),
353 new ParsePosition(13), null, 13, false);
354 parseObjectTest(NumberFormat.getPercentInstance(),
356 new ParsePosition(0), new Double(20.123), 0, false);
357 parseObjectTest(NumberFormat.getPercentInstance(),
359 new ParsePosition(0), null, 0, false);
362 // Regression for HARMONY-1685
364 NumberFormat.getInstance().parseObject("test", null);
365 fail("NullPointerException expected");
366 } catch (NullPointerException e) {
371 void parseObjectTest(NumberFormat nf, String sourseStr, ParsePosition position,
372 Object resultObj, int outIndex, boolean isSuccess) {
373 int indexBefore = position.getIndex();
374 Object result = nf.parseObject(sourseStr, position);
376 assertEquals(resultObj, result);
377 assertEquals(outIndex, position.getIndex());
380 assertEquals(indexBefore, position.getIndex());
381 assertEquals(outIndex, position.getErrorIndex());
386 * @tests java.text.NumberFormat#clone()
389 level = TestLevel.COMPLETE,
394 public void test_clone() {
396 int max_digits = 100;
397 NumberFormat nf1 = NumberFormat.getInstance();
398 nf1.setMaximumIntegerDigits(max_digits);
400 NumberFormat nf2 = (NumberFormat) nf1.clone();
401 NumberFormat nf3 = (NumberFormat) nf1.clone();
403 assertTrue("Clonned object is not equal to object", nf2.equals(nf1));
404 assertTrue("Two clonned objects are not equal", nf2.equals(nf3));
406 assertTrue("Max digits value is incorrect for clonned object", nf2
407 .getMaximumIntegerDigits() == max_digits);
409 nf1.setMaximumIntegerDigits(10);
411 "Max digits value is incorrect for clonned object after changing this value for object",
412 nf2.getMaximumIntegerDigits() == max_digits);
416 * @tests java.text.NumberFormat#equals(Object)
419 level = TestLevel.COMPLETE,
422 args = {java.lang.Object.class}
424 public void test_equals() {
426 NumberFormat nf1 = NumberFormat.getInstance();
427 NumberFormat nf2 = NumberFormat.getInstance();
429 assertTrue("Objects are not equal", nf1.equals(nf2));
430 assertTrue("THe same Objects are not equal", nf1.equals(nf1));
432 nf2.setMaximumIntegerDigits(100);
433 assertFalse("Different NumberFormat are equal", nf1.equals(nf2));
435 nf2.setMaximumIntegerDigits(nf1.getMaximumIntegerDigits());
436 assertTrue("THe same Objects are not equal", nf1.equals(nf2));
438 nf1 = NumberFormat.getIntegerInstance();
439 nf2 = NumberFormat.getIntegerInstance(Locale.CHINA);
440 assertFalse("Different NumberFormat are equal", nf1.equals(nf2));
442 assertFalse("Object is equal null", nf1.equals(null));
446 * @tests java.text.NumberFormat#format(double)
449 level = TestLevel.COMPLETE,
452 args = {double.class}
454 @KnownFailure("Some locales were removed last minute in cupcake")
455 public void test_formatLdouble() {
456 // BEGIN android-changed
457 NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
459 // NumberFormat nf2 = NumberFormat.getInstance(new Locale("ar", "AR"));
460 NumberFormat nf2 = NumberFormat.getInstance(new Locale("de", "CH"));
462 String out = nf1.format(1234567890.0123456789);
463 assertEquals("Wrong result for double : " + out, "1,234,567,890.012",
466 out = nf1.format(-1234567890.0123456789);
467 assertEquals("Wrong result for double : " + out, "-1,234,567,890.012",
470 out = nf2.format(-1234567890.0123456789);
472 // assertEquals("Wrong result for double : " + out, "1,234,567,890.012-",
474 assertEquals("Wrong result for double : " + out, "-1'234'567'890.012",
477 out = nf1.format(1.0001);
478 assertEquals("Wrong result for for double: " + out, "1", out.toString());
480 out = nf1.format(5.0);
481 assertEquals("Wrong result for for double: " + out, "5", out.toString());
482 // END android-changed
486 * @tests java.text.NumberFormat#format(long)
489 level = TestLevel.COMPLETE,
494 @KnownFailure("Some locales were removed last minute in cupcake")
495 public void test_formatLlong() {
496 // BEGIN android-changed
497 NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
499 // NumberFormat nf2 = NumberFormat.getInstance(Locale.CANADA_FRENCH);
500 NumberFormat nf2 = NumberFormat.getInstance(new Locale("de", "CH"));
502 String out = nf1.format(Long.MAX_VALUE);
503 assertEquals("Wrong result for double : " + out,
504 "9,223,372,036,854,775,807", out.toString());
506 out = nf1.format(Long.MIN_VALUE);
507 assertEquals("Wrong result for double : " + out,
508 "-9,223,372,036,854,775,808", out.toString());
510 out = nf2.format(-1234567890);
512 // assertEquals("Wrong result for double : " + out, "-1 234 567 890", out
514 assertEquals("Wrong result for double : " + out, "-1'234'567'890", out
517 // the Locale data of icu uses \uc2a0
519 assertEquals("Wrong result for for double: " + out, "1", out.toString());
522 assertEquals("Wrong result for for double: " + out, "0", out.toString());
523 // END android-changed
527 * @tests java.text.NumberFormat#getAvailableLocales()
530 level = TestLevel.COMPLETE,
532 method = "getAvailableLocales",
535 public void test_getAvailableLocales() {
537 Locale[] l = NumberFormat.getAvailableLocales();
538 assertFalse("returned Locale array is null", l == null);
539 assertTrue("returned Locale length <= 0", l.length > 0);
540 Locale[] resl = Locale.getAvailableLocales();
541 assertTrue("returned Locale arrays are different",
542 l.length == resl.length);
543 boolean isUS = false;
544 for (int i = 0; i < resl.length; i++) {
545 assertEquals("elements " + i + " are not equal: ", resl[i], l[i]);
546 if (l[i].equals(Locale.US))
549 assertTrue("there is no Locale.US", isUS);
553 * @tests java.text.NumberFormat#getCurrencyInstance()
556 level = TestLevel.COMPLETE,
558 method = "getCurrencyInstance",
561 public void test_getCurrencyInstance() {
563 Locale.setDefault(Locale.US);
564 NumberFormat format = NumberFormat.getCurrencyInstance();
566 assertNotSame("Instance is null", null, format);
567 assertTrue("Object is not instance of NumberFormat",
568 format instanceof NumberFormat);
571 "Test1: NumberFormat.getCurrencyInstance().format(35.76) returned wrong value",
572 "$35.76", format.format(35.76));
574 "Test2: NumberFormat.getCurrencyInstance().format(123456.789) returned wrong value",
575 "$123,456.79", format.format(123456.789));
577 "Test3: NumberFormat.getCurrencyInstance().format(0.1) returned wrong value",
578 "$0.10", format.format(0.1));
580 "Test4: NumberFormat.getCurrencyInstance().format(0.999) returned wrong value",
581 "$1.00", format.format(0.999));
585 * @tests java.text.NumberFormat#getCurrencyInstance(java.util.Locale)
588 level = TestLevel.COMPLETE,
590 method = "getCurrencyInstance",
591 args = {java.util.Locale.class}
593 @KnownFailure("Some locales were removed last minute in cupcake")
594 public void test_getCurrencyInstanceLjava_util_Locale() {
595 // BEGIN android-changed
596 Locale usLocale = Locale.US;
598 // Locale mkLocale = new Locale("mk", "MK");
599 Locale atLocale = new Locale("de", "AT");
601 NumberFormat format = NumberFormat.getCurrencyInstance(usLocale);
603 assertNotSame("Instance is null", null, format);
604 assertTrue("Object is not instance of NumberFormat",
605 format instanceof NumberFormat);
608 "Test1: NumberFormat.getCurrencyInstance(Locale.US).format(35.76) returned wrong value",
609 "$35.76", format.format(35.76));
611 "Test2: NumberFormat.getCurrencyInstance(Locale.US).format(123456.789) returned wrong value",
612 "$123,456.79", format.format(123456.789));
614 "Test3: NumberFormat.getCurrencyInstance(Locale.US).format(0.1) returned wrong value",
615 "$0.10", format.format(0.1));
617 "Test4: NumberFormat.getCurrencyInstance(Locale.US).format(0.999) returned wrong value",
618 "$1.00", format.format(0.999));
621 // format = NumberFormat.getCurrencyInstance(mkLocale);
622 format = NumberFormat.getCurrencyInstance(atLocale);
625 "Test5: NumberFormat.getCurrencyInstance(new Locale(\"de\", \"AT\")).format(35.76) returned wrong value",
626 "\u20ac 35,76", format.format(35.76));
628 "Test6: NumberFormat.getCurrencyInstance(new Locale(\"de\", \"AT\")).format(123456.789) returned wrong value",
629 "\u20ac 123.456,79", format.format(123456.789));
631 "Test7: NumberFormat.getCurrencyInstance(new Locale(\"de\", \"AT\")).format(0.1) returned wrong value",
632 "\u20ac 0,10", format.format(0.1));
634 "Test8: NumberFormat.getCurrencyInstance(new Locale(\"de\", \"AT\")).format(0.999) returned wrong value",
635 "\u20ac 1,00", format.format(0.999));
638 "Test5: NumberFormat.getCurrencyInstance(new Locale(\"mk\", \"MK\")).format(35.76) returned wrong value",
639 "Den 35,76", format.format(35.76));
641 "Test6: NumberFormat.getCurrencyInstance(new Locale(\"mk\", \"MK\")).format(123456.789) returned wrong value",
642 "Den 123.456,79", format.format(123456.789));
644 "Test7: NumberFormat.getCurrencyInstance(new Locale(\"mk\", \"MK\")).format(0.1) returned wrong value",
645 "Den 0,1", format.format(0.1));
647 "Test8: NumberFormat.getCurrencyInstance(new Locale(\"mk\", \"MK\")).format(0.999) returned wrong value",
648 "Den 1", format.format(0.999));*/
650 NumberFormat.getCurrencyInstance(null);
651 fail("java.lang.NullPointerException is not thrown");
652 } catch (java.lang.NullPointerException npe) {
655 // END android-changed
659 * @tests java.text.NumberFormat#getInstance()
662 level = TestLevel.COMPLETE,
664 method = "getInstance",
667 public void test_getInstance() {
668 Locale.setDefault(Locale.US);
669 NumberFormat format = NumberFormat.getInstance();
671 assertNotSame("Instance is null", null, format);
672 assertTrue("Object is not instance of NumberFormat",
673 format instanceof NumberFormat);
676 "Test1: NumberFormat.getInstance().format(1234567890.0987654321) returned wrong value",
677 "1,234,567,890.099", format.format(1234567890.0987654321));
679 "Test2: ((DecimalFormat) NumberFormat.getInstance()).toPattern returned wrong value",
680 "#,##0.###", ((DecimalFormat) format).toPattern());
682 "Test3: NumberFormat.getInstance().format(123456789) returned wrong value",
683 "123,456,789", format.format(123456789));
687 * @tests java.text.NumberFormat#getInstance(Locale)
690 level = TestLevel.COMPLETE,
692 method = "getInstance",
693 args = {java.util.Locale.class}
695 @KnownFailure("Some locales were removed last minute in cupcake")
696 public void test_getInstanceLjava_util_Locale() {
697 // BEGIN android-changed
698 Locale.setDefault(Locale.US);
700 // NumberFormat format = NumberFormat.getInstance(new Locale("ar", "AR"));
701 NumberFormat format = NumberFormat.getInstance(new Locale("de", "CH"));
703 assertNotSame("Instance is null", null, format);
704 assertTrue("Object is not instance of NumberFormat",
705 format instanceof NumberFormat);
708 "Test1: NumberFormat.getInstance().format(1234567890.0987654321) returned wrong value",
709 "1'234'567'890.099", format.format(1234567890.0987654321));
711 "Test2: ((DecimalFormat) NumberFormat.getInstance()).toPattern returned wrong value",
712 "#,##0.###", ((DecimalFormat) format).toPattern());
714 "Test3: NumberFormat.getInstance().format(123456789) returned wrong value",
715 "123'456'789", format.format(123456789));
718 "Test1: NumberFormat.getInstance().format(1234567890.0987654321) returned wrong value",
719 "1,234,567,890.099", format.format(1234567890.0987654321));
721 "Test2: ((DecimalFormat) NumberFormat.getInstance()).toPattern returned wrong value",
722 "#,##0.###;#,##0.###-", ((DecimalFormat) format).toPattern());
724 "Test3: NumberFormat.getInstance().format(123456789) returned wrong value",
725 "123,456,789", format.format(123456789));*/
727 NumberFormat.getInstance(null);
728 fail("java.lang.NullPointerException is not thrown");
729 } catch (java.lang.NullPointerException npe) {
732 // END android-changed
736 * @tests java.text.NumberFormat#getNumberInstance()
739 level = TestLevel.COMPLETE,
741 method = "getNumberInstance",
744 public void test_getNumberInstance() {
745 Locale.setDefault(Locale.US);
746 NumberFormat format = NumberFormat.getNumberInstance();
748 assertNotSame("Instance is null", null, format);
749 assertTrue("Object is not instance of NumberFormat",
750 format instanceof NumberFormat);
753 "Test1: NumberFormat.getNumberInstance().format(1234567890.0987654321) returned wrong value",
754 "1,234,567,890.099", format.format(1234567890.0987654321));
756 "Test2: ((DecimalFormat) NumberFormat.getNumberInstance()).toPattern returned wrong value",
757 "#,##0.###", ((DecimalFormat) format).toPattern());
759 "Test3: NumberFormat.getNumberInstance().format(123456789) returned wrong value",
760 "123,456,789", format.format(123456789));
764 * @tests java.text.NumberFormat#getNumberInstance(Locale)
767 level = TestLevel.COMPLETE,
769 method = "getNumberInstance",
770 args = {java.util.Locale.class}
772 @KnownFailure("Some locales were removed last minute in cupcake")
773 public void test_getNumberInstanceLjava_util_Locale() {
774 // BEGIN android-changed
775 Locale.setDefault(Locale.US);
777 NumberFormat format = NumberFormat.getNumberInstance(new Locale("de",
779 // NumberFormat format = NumberFormat.getNumberInstance(new Locale("ar",
782 assertNotSame("Instance is null", null, format);
783 assertTrue("Object is not instance of NumberFormat",
784 format instanceof NumberFormat);
787 "Test1: NumberFormat.getNumberInstance().format(-1234567890.0987654321) returned wrong value",
788 "-1'234'567'890.099", format.format(-1234567890.0987654321));
790 "Test2: ((DecimalFormat) NumberFormat.getNumberInstance()).toPattern returned wrong value",
791 "#,##0.###", ((DecimalFormat) format).toPattern());
793 "Test3: NumberFormat.getNumberInstance().format(123456789) returned wrong value",
794 "123'456'789", format.format(123456789));
797 "Test1: NumberFormat.getNumberInstance().format(-1234567890.0987654321) returned wrong value",
798 "1,234,567,890.099-", format.format(-1234567890.0987654321));
800 "Test2: ((DecimalFormat) NumberFormat.getNumberInstance()).toPattern returned wrong value",
801 "#,##0.###;#,##0.###-", ((DecimalFormat) format).toPattern());
803 "Test3: NumberFormat.getNumberInstance().format(123456789) returned wrong value",
804 "123,456,789", format.format(123456789));*/
806 NumberFormat.getInstance(null);
807 fail("java.lang.NullPointerException is not thrown");
808 } catch (java.lang.NullPointerException npe) {
811 // END android-changed
815 * @tests java.text.NumberFormat#getPercentInstance()
818 level = TestLevel.COMPLETE,
820 method = "getPercentInstance",
823 public void test_getPercentInstance() {
824 Locale.setDefault(Locale.US);
825 NumberFormat format = NumberFormat.getPercentInstance();
827 assertNotSame("Instance is null", null, format);
828 assertTrue("Object is not instance of NumberFormat",
829 format instanceof NumberFormat);
832 "Test1: NumberFormat.getPercentInstance().format(1234567890.0987654321) returned wrong value",
833 "123,456,789,010%", format.format(1234567890.0987654321));
835 "Test2: ((DecimalFormat) NumberFormat.getPercentInstance()).toPattern returned wrong value",
836 "#,##0%", ((DecimalFormat) format).toPattern());
838 "Test3: NumberFormat.getPercentInstance().format(123456789) returned wrong value",
839 "12,345,678,900%", format.format(123456789));
843 * @tests java.text.NumberFormat#getPercentInstance(Locale)
846 level = TestLevel.COMPLETE,
848 method = "getPercentInstance",
849 args = {java.util.Locale.class}
851 @KnownFailure("Some locales were removed last minute in cupcake")
852 public void test_getPercentInstanceLjava_util_Locale() {
853 Locale.setDefault(Locale.US);
854 NumberFormat format = NumberFormat.getPercentInstance(new Locale("cs",
857 assertNotSame("Instance is null", null, format);
858 assertTrue("Object is not instance of NumberFormat",
859 format instanceof NumberFormat);
862 "Test1: NumberFormat.getPercentInstance().format(1234567890.0987654321) returned wrong value",
863 "123\u00a0456\u00a0789\u00a0010%", format.format(1234567890.0987654321));
865 "Test2: ((DecimalFormat) NumberFormat.getPercentInstance()).toPattern returned wrong value",
866 "#,##0%", ((DecimalFormat) format).toPattern());
868 "Test3: NumberFormat.getPercentInstance().format(123456789) returned wrong value",
869 "12\u00a0345\u00a0678\u00a0900%", format.format(123456789));
871 NumberFormat.getInstance(null);
872 fail("java.lang.NullPointerException is not thrown");
873 } catch (java.lang.NullPointerException npe) {
879 * @tests java.text.NumberFormat#getMaximumFractionDigits()
882 level = TestLevel.COMPLETE,
884 method = "getMaximumFractionDigits",
887 public void test_getMaximumFractionDigits() {
888 NumberFormat nf1 = NumberFormat.getInstance();
890 nf1.setMaximumFractionDigits(Integer.MAX_VALUE);
891 int result = nf1.getMaximumFractionDigits();
892 assertTrue("getMaximumFractionDigits returns " + result
893 + " instead of: " + Integer.MAX_VALUE,
894 result == Integer.MAX_VALUE);
896 nf1.setMaximumFractionDigits(0);
897 result = nf1.getMaximumFractionDigits();
898 assertTrue("getMaximumFractionDigits returns " + result
899 + " instead of 0", result == 0);
901 nf1.setMinimumFractionDigits(Integer.MAX_VALUE);
902 result = nf1.getMaximumFractionDigits();
903 assertTrue("getMaximumFractionDigits returns " + result
904 + " instead of Integer.MAX_VALUE", result == Integer.MAX_VALUE);
908 * @tests java.text.NumberFormat#getMinimumFractionDigits()
911 level = TestLevel.COMPLETE,
913 method = "getMinimumFractionDigits",
916 public void test_getMinimumFractionDigits() {
917 NumberFormat nf1 = NumberFormat.getInstance();
918 nf1.setMinimumFractionDigits(Integer.MAX_VALUE);
919 int result = nf1.getMinimumFractionDigits();
920 assertTrue("getMinimumFractionDigits returns " + result
921 + " instead of: " + Integer.MAX_VALUE,
922 result == Integer.MAX_VALUE);
924 nf1.setMaximumFractionDigits(0);
925 result = nf1.getMinimumFractionDigits();
926 assertTrue("getMinimumFractionDigits returns " + result
927 + " instead of 0", result == 0);
929 nf1.setMinimumFractionDigits(52);
930 result = nf1.getMinimumFractionDigits();
931 assertTrue("getMinimumFractionDigits returns " + result
932 + " instead of 52", result == 52);
936 * @tests java.text.NumberFormat#getMaximumIntegerDigits()
939 level = TestLevel.COMPLETE,
941 method = "getMaximumIntegerDigits",
944 public void test_getMaximumIntegerDigits() {
945 NumberFormat nf1 = NumberFormat.getInstance();
946 nf1.setMaximumIntegerDigits(Integer.MAX_VALUE);
947 int result = nf1.getMaximumIntegerDigits();
948 assertTrue("getMaximumIntegerDigits returns " + result
949 + " instead of: " + Integer.MAX_VALUE,
950 result == Integer.MAX_VALUE);
952 nf1.setMaximumIntegerDigits(0);
953 result = nf1.getMaximumIntegerDigits();
954 assertTrue("getMaximumIntegerDigits returns " + result
955 + " instead of 0", result == 0);
957 nf1.setMinimumIntegerDigits(Integer.MAX_VALUE);
958 result = nf1.getMaximumIntegerDigits();
959 assertTrue("getMaximumIntegerigits returns " + result
960 + " instead of Integer.MAX_VALUE", result == Integer.MAX_VALUE);
964 * @tests java.text.NumberFormat#getMinimumIntegerDigits()
967 level = TestLevel.COMPLETE,
969 method = "getMinimumIntegerDigits",
972 public void test_getMinimumIntegernDigits() {
973 NumberFormat nf1 = NumberFormat.getInstance();
974 nf1.setMinimumIntegerDigits(Integer.MAX_VALUE);
975 int result = nf1.getMinimumIntegerDigits();
976 assertTrue("getMinimumIntegerDigits returns " + result
977 + " instead of: " + Integer.MAX_VALUE,
978 result == Integer.MAX_VALUE);
980 nf1.setMaximumIntegerDigits(0);
981 result = nf1.getMinimumIntegerDigits();
982 assertTrue("getMinimumIntegerDigits returns " + result
983 + " instead of 0", result == 0);
985 nf1.setMinimumIntegerDigits(0x12034);
986 result = nf1.getMinimumIntegerDigits();
987 assertTrue("getMinimumIntegerDigits returns " + result
988 + " instead of 5148", result == 73780);
992 * @tests java.text.NumberFormat#hashCode()
995 level = TestLevel.COMPLETE,
1000 public void test_hashCode() {
1002 NumberFormat nf1 = NumberFormat.getInstance();
1003 NumberFormat nf11 = NumberFormat.getInstance();
1004 NumberFormat nf2 = NumberFormat.getInstance(Locale.US);
1005 NumberFormat nf3 = NumberFormat.getPercentInstance();
1006 NumberFormat nf4 = NumberFormat.getCurrencyInstance();
1007 NumberFormat nf5 = NumberFormat
1008 .getNumberInstance(new Locale("mk", "MK"));
1009 NumberFormat nf6 = NumberFormat.getInstance(Locale.US);
1011 assertTrue("Hash codes are not equal: case 1", nf1.hashCode() == nf2
1013 assertTrue("Hash codes are not equal: case 2", nf1.hashCode() == nf11
1015 assertTrue("Hash codes are not equal: case 3", nf1.hashCode() == nf3
1017 assertFalse("Hash codes are equal: case 4", nf3.hashCode() == nf4
1019 assertFalse("Hash codes are equal: case 5", nf4.hashCode() == nf5
1021 assertTrue("Hash codes are not equal: case 6", nf5.hashCode() == nf6
1024 nf1.setMaximumFractionDigits(0);
1025 assertTrue("Hash codes are not equal: case 7", nf1.hashCode() == nf11
1030 * @tests java.text.NumberFormat#isGroupingUsed()
1033 level = TestLevel.COMPLETE,
1035 method = "isGroupingUsed",
1038 public void test_isGroupingUsed() {
1039 NumberFormat nf1 = NumberFormat.getInstance();
1040 assertTrue("grouping is not used for NumberFormat.getInstance", nf1
1043 nf1.setGroupingUsed(false);
1045 "grouping is used for NumberFormat.getInstance after setting false",
1046 nf1.isGroupingUsed());
1048 nf1.setGroupingUsed(true);
1050 "grouping is not used for NumberFormat.getInstance after setting true",
1051 nf1.isGroupingUsed());
1055 * @tests java.text.NumberFormat#setGroupingUsed(boolean)
1058 level = TestLevel.COMPLETE,
1060 method = "setGroupingUsed",
1061 args = {boolean.class}
1063 @KnownFailure("Some locales were removed last minute in cupcake")
1064 public void test_setGroupingUsed() {
1065 NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
1066 nf1.setGroupingUsed(false);
1068 assertEquals("grouping is used for 1234567890.1", "1234567890.1",
1069 nf1.format(1234567890.1));
1071 assertEquals("grouping is used for -1234567890.1", "-1234567890.1",
1072 nf1.format(-1234567890.1));
1074 nf1.setGroupingUsed(false);
1076 assertEquals("grouping is used for 1234567890.1", "1234567890.1",
1077 nf1.format(1234567890.1));
1079 assertEquals("grouping is used for -1234567890.1", "-1234567890.1",
1080 nf1.format(-1234567890.1));
1082 nf1.setGroupingUsed(true);
1084 assertEquals("grouping is not used for 1234567890.1",
1085 "1,234,567,890.1", nf1.format(1234567890.1));
1087 assertEquals("grouping is not used for -1234567890.1",
1088 "-1,234,567,890.1", nf1.format(-1234567890.1));
1090 NumberFormat nf2 = NumberFormat.getPercentInstance(new Locale("cs",
1092 nf2.setGroupingUsed(false);
1094 "Locale(\"cs\", \"CZ\"): grouping is used for 1234567890.1",
1095 "123456789010%", nf2.format(1234567890.1));
1098 "Locale(\"cs\", \"CZ\"): grouping is used for -1234567890.1",
1099 "-123456789010%", nf2.format(-1234567890.1));
1100 assertEquals("grouping is not used for 1234567890.1",
1101 "1,234,567,890.1", nf1.format(1234567890.1));
1103 nf2.setGroupingUsed(true);
1105 "Locale(\"cs\", \"CZ\"): grouping is not used for 1234567890.1",
1106 "123\u00a0456\u00a0789\u00a0010%", nf2.format(1234567890.1));
1109 "Locale(\"cs\", \"CZ\"): grouping is not used for -1234567890.1",
1110 "-123\u00a0456\u00a0789\u00a0010%", nf2.format(-1234567890.1));
1112 nf2.setGroupingUsed(true);
1114 "Locale(\"cs\", \"CZ\"): grouping is not used for 1234567890.1",
1115 "123\u00a0456\u00a0789\u00a0010%", nf2.format(1234567890.1));
1118 "Locale(\"cs\", \"CZ\"): grouping is not used for -1234567890.1",
1119 "-123\u00a0456\u00a0789\u00a0010%", nf2.format(-1234567890.1));
1123 * @tests java.text.NumberFormat#isParseIntegerOnly()
1126 level = TestLevel.COMPLETE,
1128 method = "isParseIntegerOnly",
1131 public void test_isParseIntegerOnly() {
1132 NumberFormat nf1 = NumberFormat.getInstance();
1133 assertTrue("ParseIntegerOnly is not used for NumberFormat.getInstance",
1134 nf1.isGroupingUsed());
1136 nf1.setParseIntegerOnly(false);
1138 "ParseIntegerOnly is used for NumberFormat.getInstance after setting false",
1139 nf1.isParseIntegerOnly());
1141 nf1.setParseIntegerOnly(true);
1143 "ParseIntegerOnly is not used for NumberFormat.getInstance after setting true",
1144 nf1.isParseIntegerOnly());
1148 * @tests java.text.NumberFormat#setParseIntegerOnly(boolean)
1151 level = TestLevel.COMPLETE,
1153 method = "setParseIntegerOnly",
1154 args = {boolean.class}
1156 public void test_setParseIntegerOnly() {
1157 NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
1158 nf1.setParseIntegerOnly(true);
1160 assertEquals("ParseIntegerOnly is not used for 1234567890.1",
1161 "1,234,567,890.1", nf1.format(1234567890.1));
1162 assertEquals("ParseIntegerOnly is not used for -1234567890.1",
1163 "-1,234,567,890.1", nf1.format(-1234567890.1));
1164 assertEquals("ParseIntegerOnly is not used for -1234567890.",
1165 "-1,234,567,890", nf1.format(-1234567890.));
1167 nf1.setParseIntegerOnly(false);
1169 assertEquals("ParseIntegerOnly is not used for 1234567890.1",
1170 "1,234,567,890.1", nf1.format(1234567890.1));
1171 assertEquals("ParseIntegerOnly is not used for -1234567890.1",
1172 "-1,234,567,890.1", nf1.format(-1234567890.1));
1173 assertEquals("ParseIntegerOnly is not used for -1234567890.",
1174 "-1,234,567,890", nf1.format(-1234567890.));
1178 * @tests java.text.NumberFormat#setMaximumFractionDigits(int)
1181 level = TestLevel.COMPLETE,
1183 method = "setMaximumFractionDigits",
1186 public void test_setMaximumFractionDigits() {
1187 NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
1188 nf1.setMaximumFractionDigits(Integer.MAX_VALUE);
1189 int result = nf1.getMaximumFractionDigits();
1190 assertTrue("setMaximumFractionDigits set " + result
1191 + " instead of Integer.MAX_VALUE", result == Integer.MAX_VALUE);
1192 nf1.setMaximumFractionDigits(0);
1193 result = nf1.getMaximumFractionDigits();
1194 assertTrue("setMaximumFractionDigits set " + result + " instead of 0",
1196 assertEquals("format of 1234567890.0987654321 returns incorrect value",
1197 "1,234,567,890", nf1.format(1234567890.0987654321));
1198 nf1.setMaximumFractionDigits(5);
1199 result = nf1.getMaximumFractionDigits();
1200 assertTrue("setMaximumFractionDigits set " + result + " instead of 5",
1203 "format of 1234567890.0987654321 returns incorrect value with MaximumFractionDigits = 5",
1204 "1,234,567,890.09877", nf1.format(1234567890.0987654321));
1206 "format of -1234567890 returns incorrect value with MaximumFractionDigits = 5",
1207 "-1,234,567,890", nf1.format(-1234567890));
1208 nf1.setMaximumFractionDigits(Integer.MIN_VALUE);
1209 result = nf1.getMaximumFractionDigits();
1210 assertTrue("setMaximumFractionDigits set " + result
1211 + " instead of Integer.MIN_VALUE", result == 0);
1213 "format of 1234567890.0987654321 returns incorrect value with MaximumFractionDigits = 5",
1214 "1,234,567,890", nf1.format(1234567890.0987654321));
1218 * @tests java.text.NumberFormat#setMinimumFractionDigits(int)
1221 level = TestLevel.COMPLETE,
1223 method = "setMinimumFractionDigits",
1226 public void test_setMinimumFractionDigits() {
1228 NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
1229 nf1.setMinimumFractionDigits(Integer.MAX_VALUE);
1230 int result = nf1.getMinimumFractionDigits();
1231 assertTrue("setMinimumFractionDigits set " + result
1232 + " instead of Integer.MAX_VALUE", result == Integer.MAX_VALUE);
1233 nf1.setMinimumFractionDigits(0);
1234 result = nf1.getMinimumFractionDigits();
1235 assertTrue("setMinimumFractionDigits set " + result + " instead of 0",
1237 nf1.setMinimumFractionDigits(5);
1238 result = nf1.getMinimumFractionDigits();
1239 assertTrue("setMinimumFractionDigits set " + result + " instead of 5",
1242 "format of 1234567890.0987654321 returns incorrect value with MinimumFractionDigits = 5",
1243 "1,234,567,890.09000", nf1.format(1234567890.09));
1245 "format of -1234567890 returns incorrect value with MinimumFractionDigits = 5",
1246 "-1,234,567,890.00000", nf1.format(-1234567890));
1247 nf1.setMinimumFractionDigits(Integer.MIN_VALUE);
1248 result = nf1.getMinimumFractionDigits();
1249 assertTrue("setMinimumFractionDigits set " + result
1250 + " instead of Integer.MIN_VALUE", result == 0);
1252 "format of 1234567890.098 returns incorrect value with MinimumFractionDigits = 5",
1253 "1,234,567,890.098", nf1.format(1234567890.098));
1257 * @tests java.text.NumberFormat#setMinimumIntegerDigits(int)
1260 level = TestLevel.COMPLETE,
1262 method = "setMinimumIntegerDigits",
1265 public void test_setMinimumIntegerDigits() {
1267 NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
1268 nf1.setMinimumIntegerDigits(Integer.MAX_VALUE);
1269 int result = nf1.getMinimumIntegerDigits();
1270 assertTrue("setMinimumIntegerDigits set " + result
1271 + " instead of Integer.MAX_VALUE", result == Integer.MAX_VALUE);
1272 nf1.setMinimumIntegerDigits(0);
1273 result = nf1.getMinimumIntegerDigits();
1274 assertTrue("setMinimumIntegerDigits set " + result + " instead of 0",
1276 nf1.setMinimumIntegerDigits(5);
1277 result = nf1.getMinimumIntegerDigits();
1278 assertTrue("setMinimumIntegerDigits set " + result + " instead of 5",
1281 "format of 123.09 returns incorrect value with MinimumIntegerDigits = 5",
1282 "00,123.09", nf1.format(123.09));
1284 "format of -123 returns incorrect value with MinimumIntegerDigits = 5",
1285 "-00,123", nf1.format(-123));
1286 nf1.setMinimumIntegerDigits(Integer.MIN_VALUE);
1287 result = nf1.getMinimumIntegerDigits();
1288 assertTrue("setMinimumIntegerDigits set " + result
1289 + " instead of Integer.MIN_VALUE", result == 0);
1293 * @tests java.text.NumberFormat#parse(String)
1296 level = TestLevel.COMPLETE,
1299 args = {java.lang.String.class}
1301 public void test_parseLjava_lang_String() {
1302 NumberFormat nf1 = NumberFormat.getInstance();
1305 "Test1: NumberFormat.getInstance().parse(\"1234567890.1\") returned wrong number",
1306 new Double(1234567890.1), nf1.parse("1234567890.1"));
1307 } catch (java.text.ParseException pe) {
1308 fail("java.text.ParseException is thrown for 1234567890.1");
1313 "Test2: NumberFormat.getInstance().parse(\"-1234567890.1\") returned wrong number",
1314 new Double(-1234567890.1), nf1.parse("-1,234,567,890.1"));
1315 } catch (java.text.ParseException pe) {
1316 fail("java.text.ParseException is thrown for -1,234,567,890.1");
1320 nf1.parse("@1,234,567,8901");
1321 fail("java.text.ParseException is not thrown for 1,234,567,890z1");
1322 } catch (java.text.ParseException pe) {
1326 nf1 = NumberFormat.getPercentInstance();
1329 "Test3: NumberFormat.getPercentInstance().parse(\"-123%\") returned wrong number",
1330 new Double(-1.23), nf1.parse("-123%"));
1331 } catch (java.text.ParseException pe) {
1332 fail("java.text.ParseException is thrown for -123%");
1335 nf1 = NumberFormat.getCurrencyInstance();
1338 "Test4: NumberFormat.getCurrencyInstance().parse(\"$123\") returned wrong number",
1339 new Long(123), nf1.parse("$123"));
1340 } catch (java.text.ParseException pe) {
1341 fail("java.text.ParseException is thrown for $123");
1346 "Test4: NumberFormat.getCurrencyInstance().parse(\"$123abc\") returned wrong number",
1347 new Long(123), nf1.parse("$123abc"));
1348 } catch (java.text.ParseException pe) {
1349 fail("java.text.ParseException is thrown for $123");
1352 nf1 = NumberFormat.getIntegerInstance();
1355 "Test5: NumberFormat.getIntegerInstance().parse(\"-123.123\") returned wrong number",
1356 nf1.parseObject("-123.123"), nf1.parse("-123.123"));
1357 } catch (java.text.ParseException pe) {
1358 fail("java.text.ParseException is thrown for $123");
1363 * @tests java.text.NumberFormat#NumberFormat()
1366 level = TestLevel.COMPLETE,
1368 method = "NumberFormat",
1371 public void test_constructor() {
1372 MyNumberFormat mf = new MyNumberFormat();
1373 assertFalse("Greated NumberFormat object is null", mf == null);
1375 "Greated NumberFormat object is not instance of NumberFormat",
1376 mf instanceof NumberFormat);
1379 class MyNumberFormat extends NumberFormat {
1380 static final long serialVersionUID = 1L;
1382 public MyNumberFormat() {
1386 public StringBuffer format(double number, StringBuffer toAppendTo,
1387 FieldPosition pos) {
1389 return new StringBuffer();
1392 public Number parse(String source, ParsePosition parsePosition) {
1394 return new Double(0);
1397 public StringBuffer format(long number, StringBuffer toAppendTo,
1398 FieldPosition pos) {
1399 return new StringBuffer();