8164791: Update existing test cases of test/java/text/Format

Reviewed-by: okutsu, peytoia
This commit is contained in:
Nancy Nigam 2016-09-15 08:18:57 +09:00 committed by Yuka Kamiya
parent cf73adbf80
commit 1d734cec8f
31 changed files with 371 additions and 337 deletions

View File

@ -50,110 +50,110 @@ public class Bug4322313 extends IntlTest {
Object[][] valids = { Object[][] valids = {
/* given ID offset format('z'), ('Z') index */ /* given ID offset format('z'), ('Z') index */
{"GMT+03:04", new Long(-184 * mpm), "GMT+03:04", "+0304", new Integer(9)}, {"GMT+03:04", -184L * mpm, "GMT+03:04", "+0304", 9},
{"GMT+13:42", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(9)}, {"GMT+13:42", -822L * mpm, "GMT+13:42", "+1342", 9},
{"GMT+00:00", new Long(0), "GMT+00:00", "+0000", new Integer(9)}, {"GMT+00:00", 0L, "GMT+00:00", "+0000", 9},
{"GMT+1:11", new Long(-71 * mpm), "GMT+01:11", "+0111", new Integer(8)}, {"GMT+1:11", -71L * mpm, "GMT+01:11", "+0111", 8},
{"GMT +13:42", new Long(0), "GMT", "+0000", new Integer(3)}, {"GMT +13:42", 0L, "GMT", "+0000", 3},
{" GMT", new Long(0), "GMT", "+0000", new Integer(4)}, {" GMT", 0L, "GMT", "+0000", 4},
{"+0304", new Long(-184 * mpm), "GMT+03:04", "+0304", new Integer(5)}, {"+0304", -184L * mpm, "GMT+03:04", "+0304", 5},
{"+1342", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(5)}, {"+1342", -822L * mpm, "GMT+13:42", "+1342", 5},
{"+0000", new Long(0), "GMT+00:00", "+0000", new Integer(5)}, {"+0000", 0L, "GMT+00:00", "+0000", 5},
{" +1342", new Long(-822 * mpm), "GMT+13:42", "+1342", new Integer(6)}, {" +1342", -822L * mpm, "GMT+13:42", "+1342", 6},
/* ISO-LATIN-1 digits */ /* ISO-LATIN-1 digits */
{"GMT+\u0030\u0031:\u0032\u0033", new Long(-83 * mpm), "GMT+01:23", "+0123", new Integer(9)}, {"GMT+\u0030\u0031:\u0032\u0033", -83L * mpm, "GMT+01:23", "+0123", 9},
/* In fact, this test case is skipped because TimeZone class can't /* In fact, this test case is skipped because TimeZone class can't
* recognize TimeZone IDs like "+00234" or "-00234". * recognize TimeZone IDs like "+00234" or "-00234".
*/ */
{"+00234", new Long(-23 * mpm), "GMT+00:23", "+0023", new Integer(5)}, {"+00234", -23L * mpm, "GMT+00:23", "+0023", 5},
{"GMT-03:04", new Long(184 * mpm), "GMT-03:04", "-0304", new Integer(9)}, {"GMT-03:04", 184L * mpm, "GMT-03:04", "-0304", 9},
{"GMT-13:42", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(9)}, {"GMT-13:42", 822L * mpm, "GMT-13:42", "-1342", 9},
{"GMT-00:00", new Long(0), "GMT+00:00", "+0000", new Integer(9)}, {"GMT-00:00", 0L, "GMT+00:00", "+0000", 9},
{"GMT-1:11", new Long(71 * mpm), "GMT-01:11", "-0111", new Integer(8)}, {"GMT-1:11", 71L * mpm, "GMT-01:11", "-0111", 8},
{"GMT -13:42", new Long(0), "GMT", "+0000", new Integer(3)}, {"GMT -13:42", 0L, "GMT", "+0000", 3},
{"-0304", new Long(184 * mpm), "GMT-03:04", "-0304", new Integer(5)}, {"-0304", 184L * mpm, "GMT-03:04", "-0304", 5},
{"-1342", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(5)}, {"-1342", 822L * mpm, "GMT-13:42", "-1342", 5},
{" -1342", new Long(822 * mpm), "GMT-13:42", "-1342", new Integer(6)}, {" -1342", 822L * mpm, "GMT-13:42", "-1342", 6},
/* ISO-LATIN-1 digits */ /* ISO-LATIN-1 digits */
{"GMT-\u0030\u0031:\u0032\u0033", new Long(83 * mpm), "GMT-01:23", "-0123", new Integer(9)}, {"GMT-\u0030\u0031:\u0032\u0033", 83L * mpm, "GMT-01:23", "-0123", 9},
/* In fact, this test case is skipped because TimeZone class can't /* In fact, this test case is skipped because TimeZone class can't
* recognize TimeZone IDs like "+00234" or "-00234". * recognize TimeZone IDs like "+00234" or "-00234".
*/ */
{"-00234", new Long(23 * mpm), "GMT+00:23", "-0023", new Integer(5)}, {"-00234", 23L * mpm, "GMT+00:23", "-0023", 5},
}; };
Object[][] invalids = { Object[][] invalids = {
/* given ID error index */ /* given ID error index */
{"GMT+8", new Integer(5)}, {"GMT+8", 5},
{"GMT+18", new Integer(6)}, {"GMT+18", 6},
{"GMT+208", new Integer(6)}, {"GMT+208", 6},
{"GMT+0304", new Integer(6)}, {"GMT+0304", 6},
{"GMT+42195", new Integer(5)}, {"GMT+42195", 5},
{"GMT+5:8", new Integer(7)}, {"GMT+5:8", 7},
{"GMT+23:60", new Integer(8)}, {"GMT+23:60", 8},
{"GMT+11:1", new Integer(8)}, {"GMT+11:1", 8},
{"GMT+24:13", new Integer(5)}, {"GMT+24:13", 5},
{"GMT+421:950", new Integer(5)}, {"GMT+421:950", 5},
{"GMT+0a:0A", new Integer(5)}, {"GMT+0a:0A", 5},
{"GMT+ 13:42", new Integer(4)}, {"GMT+ 13:42", 4},
{"GMT+13 :42", new Integer(6)}, {"GMT+13 :42", 6},
{"GMT+13: 42", new Integer(7)}, {"GMT+13: 42", 7},
{"GMT+-13:42", new Integer(4)}, {"GMT+-13:42", 4},
{"G M T", new Integer(0)}, {"G M T", 0},
{"+8", new Integer(2)}, {"+8", 2},
{"+18", new Integer(3)}, {"+18", 3},
{"+208", new Integer(4)}, {"+208", 4},
{"+2360", new Integer(4)}, {"+2360", 4},
{"+2413", new Integer(2)}, {"+2413", 2},
{"+42195", new Integer(2)}, {"+42195", 2},
{"+0AbC", new Integer(2)}, {"+0AbC", 2},
{"+ 1342", new Integer(1)}, {"+ 1342", 1},
{"+-1342", new Integer(1)}, {"+-1342", 1},
{"1342", new Integer(0)}, {"1342", 0},
/* Arabic-Indic digits */ /* Arabic-Indic digits */
{"GMT+\u0660\u0661:\u0662\u0663", new Integer(4)}, {"GMT+\u0660\u0661:\u0662\u0663", 4},
/* Extended Arabic-Indic digits */ /* Extended Arabic-Indic digits */
{"GMT+\u06f0\u06f1:\u06f2\u06f3", new Integer(4)}, {"GMT+\u06f0\u06f1:\u06f2\u06f3", 4},
/* Devanagari digits */ /* Devanagari digits */
{"GMT+\u0966\u0967:\u0968\u0969", new Integer(4)}, {"GMT+\u0966\u0967:\u0968\u0969", 4},
/* Fullwidth digits */ /* Fullwidth digits */
{"GMT+\uFF10\uFF11:\uFF12\uFF13", new Integer(4)}, {"GMT+\uFF10\uFF11:\uFF12\uFF13", 4},
{"GMT-8", new Integer(5)}, {"GMT-8", 5},
{"GMT-18", new Integer(6)}, {"GMT-18", 6},
{"GMT-208", new Integer(6)}, {"GMT-208", 6},
{"GMT-0304", new Integer(6)}, {"GMT-0304", 6},
{"GMT-42195", new Integer(5)}, {"GMT-42195", 5},
{"GMT-5:8", new Integer(7)}, {"GMT-5:8", 7},
{"GMT-23:60", new Integer(8)}, {"GMT-23:60", 8},
{"GMT-11:1", new Integer(8)}, {"GMT-11:1", 8},
{"GMT-24:13", new Integer(5)}, {"GMT-24:13", 5},
{"GMT-421:950", new Integer(5)}, {"GMT-421:950", 5},
{"GMT-0a:0A", new Integer(5)}, {"GMT-0a:0A", 5},
{"GMT- 13:42", new Integer(4)}, {"GMT- 13:42", 4},
{"GMT-13 :42", new Integer(6)}, {"GMT-13 :42", 6},
{"GMT-13: 42", new Integer(7)}, {"GMT-13: 42", 7},
{"GMT-+13:42", new Integer(4)}, {"GMT-+13:42", 4},
{"-8", new Integer(2)}, {"-8", 2},
{"-18", new Integer(3)}, {"-18", 3},
{"-208", new Integer(4)}, {"-208", 4},
{"-2360", new Integer(4)}, {"-2360", 4},
{"-2413", new Integer(2)}, {"-2413", 2},
{"-42195", new Integer(2)}, {"-42195", 2},
{"-0AbC", new Integer(2)}, {"-0AbC", 2},
{"- 1342", new Integer(1)}, {"- 1342", 1},
{"--1342", new Integer(1)}, {"--1342", 1},
{"-802", new Integer(2)}, {"-802", 2},
/* Arabic-Indic digits */ /* Arabic-Indic digits */
{"GMT-\u0660\u0661:\u0662\u0663", new Integer(4)}, {"GMT-\u0660\u0661:\u0662\u0663", 4},
/* Extended Arabic-Indic digits */ /* Extended Arabic-Indic digits */
{"GMT-\u06f0\u06f1:\u06f2\u06f3", new Integer(4)}, {"GMT-\u06f0\u06f1:\u06f2\u06f3", 4},
/* Devanagari digits */ /* Devanagari digits */
{"GMT-\u0966\u0967:\u0968\u0969", new Integer(4)}, {"GMT-\u0966\u0967:\u0968\u0969", 4},
/* Fullwidth digits */ /* Fullwidth digits */
{"GMT-\uFF10\uFF11:\uFF12\uFF13", new Integer(4)}, {"GMT-\uFF10\uFF11:\uFF12\uFF13", 4},
}; };
try { try {

View File

@ -30,6 +30,7 @@
import java.text.*; import java.text.*;
import java.util.*; import java.util.*;
@SuppressWarnings("deprecation")
public class Bug4736959 { public class Bug4736959 {
/** /**
* 4736959: JSpinner won't work for AM/PM field * 4736959: JSpinner won't work for AM/PM field

View File

@ -685,8 +685,8 @@ public class Bug4823811 {
testNumberFormatFormatting(nfEG, -456, "456-", "ar_EG"); testNumberFormatFormatting(nfEG, -456, "456-", "ar_EG");
System.out.println("*** DecimalFormat.parse test in ar_EG"); System.out.println("*** DecimalFormat.parse test in ar_EG");
testNumberFormatParsing(nfEG, "123-", new Long(-123), "ar_EG"); testNumberFormatParsing(nfEG, "123-", -123L, "ar_EG");
testNumberFormatParsing(nfEG, "123--", new Long(-123), "ar_EG"); testNumberFormatParsing(nfEG, "123--",-123L, "ar_EG");
testNumberFormatParsingCheckException(nfEG, "-123", 0, "ar_EG"); testNumberFormatParsingCheckException(nfEG, "-123", 0, "ar_EG");
System.out.println("*** DecimalFormat.format test in en_US"); System.out.println("*** DecimalFormat.format test in en_US");
@ -694,8 +694,8 @@ public class Bug4823811 {
testNumberFormatFormatting(nfUS, -456, "-456", "en_US"); testNumberFormatFormatting(nfUS, -456, "-456", "en_US");
System.out.println("*** DecimalFormat.parse test in en_US"); System.out.println("*** DecimalFormat.parse test in en_US");
testNumberFormatParsing(nfUS, "123-", new Long(123), "en_US"); testNumberFormatParsing(nfUS, "123-", 123L, "en_US");
testNumberFormatParsing(nfUS, "-123", new Long(-123), "en_US"); testNumberFormatParsing(nfUS, "-123",-123L, "en_US");
testNumberFormatParsingCheckException(nfUS, "--123", 0, "en_US"); testNumberFormatParsingCheckException(nfUS, "--123", 0, "en_US");
} }

View File

@ -55,6 +55,7 @@ public class Bug4845901 {
} }
} }
@SuppressWarnings("deprecation")
static void testParse(SimpleDateFormat sdf, String str, int expectedHour) { static void testParse(SimpleDateFormat sdf, String str, int expectedHour) {
try { try {
Date parsedDate = sdf.parse(str); Date parsedDate = sdf.parse(str);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -37,6 +37,7 @@ public class Bug6609750 {
Locale defaultLocale = Locale.getDefault(); Locale defaultLocale = Locale.getDefault();
Locale.setDefault(Locale.US); Locale.setDefault(Locale.US);
@SuppressWarnings("deprecation")
Date[] dates = { Date[] dates = {
new Date(9-1900, Calendar.JUNE, 12), new Date(9-1900, Calendar.JUNE, 12),
new Date(99-1900, Calendar.JUNE, 12), new Date(99-1900, Calendar.JUNE, 12),

View File

@ -66,6 +66,7 @@ public class Bug6683975 {
System.err.println("\tth_TH: " + str_th_TH); System.err.println("\tth_TH: " + str_th_TH);
} }
@SuppressWarnings("deprecation")
Date date = new Date(2008-1900, Calendar.SEPTEMBER, 30, 8, 0, 0); Date date = new Date(2008-1900, Calendar.SEPTEMBER, 30, 8, 0, 0);
str_th = df_th.format(date); str_th = df_th.format(date);
if (!expected_th[style].equals(str_th)) { if (!expected_th[style].equals(str_th)) {

View File

@ -41,7 +41,7 @@ public class DateFormatRegression extends IntlTest {
} }
public void Test4029195() { public void Test4029195() {
@SuppressWarnings("deprecation")
Date today = new Date(); Date today = new Date();
logln("today: " + today); logln("today: " + today);
@ -74,19 +74,20 @@ public class DateFormatRegression extends IntlTest {
public void Test4052408() { public void Test4052408() {
DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT,
DateFormat.SHORT, Locale.US); DateFormat.SHORT, Locale.US);
@SuppressWarnings("deprecation")
Date date = new Date(97, Calendar.MAY, 3, 8, 55); Date date = new Date(97, Calendar.MAY, 3, 8, 55);
String str; String str;
logln(str = fmt.format(date)); logln(str = fmt.format(date));
if (!str.equals("5/3/97 8:55 AM")) if (!str.equals("5/3/97 8:55 AM"))
errln("Fail: Test broken; Want 5/3/97 8:55 AM Got " + str); errln("Fail: Test broken; Want 5/3/97 8:55 AM Got " + str);
Hashtable expected = new Hashtable(); Map<Integer,String> expected = new HashMap<>();
expected.put(new Integer(DateFormat.MONTH_FIELD), "5"); expected.put(DateFormat.MONTH_FIELD, "5");
expected.put(new Integer(DateFormat.DATE_FIELD), "3"); expected.put(DateFormat.DATE_FIELD, "3");
expected.put(new Integer(DateFormat.YEAR_FIELD), "97"); expected.put(DateFormat.YEAR_FIELD, "97");
expected.put(new Integer(DateFormat.HOUR1_FIELD), "8"); expected.put(DateFormat.HOUR1_FIELD, "8");
expected.put(new Integer(DateFormat.MINUTE_FIELD), "55"); expected.put(DateFormat.MINUTE_FIELD, "55");
expected.put(new Integer(DateFormat.AM_PM_FIELD), "AM"); expected.put(DateFormat.AM_PM_FIELD, "AM");
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
String fieldNames[] = { String fieldNames[] = {
@ -120,7 +121,7 @@ public class DateFormatRegression extends IntlTest {
", \"" + str + "\", " + ", \"" + str + "\", " +
pos.getBeginIndex() + ", " + pos.getBeginIndex() + ", " +
pos.getEndIndex()); pos.getEndIndex());
String exp = (String) expected.get(new Integer(i)); String exp = expected.get(i);
if ((exp == null && str.length() == 0) || if ((exp == null && str.length() == 0) ||
str.equals(exp)) str.equals(exp))
logln(" ok"); logln(" ok");
@ -135,6 +136,7 @@ public class DateFormatRegression extends IntlTest {
/** /**
* Verify the function of the [s|g]et2DigitYearStart() API. * Verify the function of the [s|g]et2DigitYearStart() API.
*/ */
@SuppressWarnings("deprecation")
public void Test4056591() { public void Test4056591() {
try { try {
SimpleDateFormat fmt = new SimpleDateFormat("yyMMdd", Locale.US); SimpleDateFormat fmt = new SimpleDateFormat("yyMMdd", Locale.US);
@ -255,6 +257,7 @@ public class DateFormatRegression extends IntlTest {
if (!ok) errln("Fail: Lenient not working"); if (!ok) errln("Fail: Lenient not working");
} }
@SuppressWarnings("deprecation")
public void Test4065240() { public void Test4065240() {
Date curDate; Date curDate;
DateFormat shortdate, fulldate; DateFormat shortdate, fulldate;
@ -297,6 +300,7 @@ public class DateFormatRegression extends IntlTest {
Currently this bug breaks MessageFormat.toPattern Currently this bug breaks MessageFormat.toPattern
*/ */
@SuppressWarnings("deprecation")
public void Test4071441() { public void Test4071441() {
DateFormat fmtA = DateFormat.getInstance(); DateFormat fmtA = DateFormat.getInstance();
DateFormat fmtB = DateFormat.getInstance(); DateFormat fmtB = DateFormat.getInstance();
@ -488,6 +492,7 @@ public class DateFormatRegression extends IntlTest {
public void Test4101483() { public void Test4101483() {
SimpleDateFormat sdf = new SimpleDateFormat("z", Locale.US); SimpleDateFormat sdf = new SimpleDateFormat("z", Locale.US);
FieldPosition fp = new FieldPosition(DateFormat.TIMEZONE_FIELD); FieldPosition fp = new FieldPosition(DateFormat.TIMEZONE_FIELD);
@SuppressWarnings("deprecation")
Date d= new Date(9234567890L); Date d= new Date(9234567890L);
StringBuffer buf = new StringBuffer(""); StringBuffer buf = new StringBuffer("");
logln(sdf.format(d, buf, fp).toString()); logln(sdf.format(d, buf, fp).toString());
@ -508,6 +513,7 @@ public class DateFormatRegression extends IntlTest {
public void Test4103340() { public void Test4103340() {
// choose a date that is the FIRST of some month // choose a date that is the FIRST of some month
// and some arbitrary time // and some arbitrary time
@SuppressWarnings("deprecation")
Date d=new Date(97, 3, 1, 1, 1, 1); Date d=new Date(97, 3, 1, 1, 1, 1);
SimpleDateFormat df=new SimpleDateFormat("MMMM", Locale.US); SimpleDateFormat df=new SimpleDateFormat("MMMM", Locale.US);
@ -538,6 +544,7 @@ public class DateFormatRegression extends IntlTest {
sdf.applyPattern(pattern); sdf.applyPattern(pattern);
logln("pattern: \"" + pattern + "\""); logln("pattern: \"" + pattern + "\"");
@SuppressWarnings("deprecation")
Object[] DATA = { Object[] DATA = {
"time 10:30", new ParsePosition(10), new Date(70, Calendar.JANUARY, 1, 10, 30), "time 10:30", new ParsePosition(10), new Date(70, Calendar.JANUARY, 1, 10, 30),
"time 10:x", new ParsePosition(0), null, "time 10:x", new ParsePosition(0), null,
@ -698,6 +705,7 @@ public class DateFormatRegression extends IntlTest {
String pattern = "'TO_DATE('''dd'-'MM'-'yyyy HH:mm:ss''' , ''DD-MM-YYYY HH:MI:SS'')'"; String pattern = "'TO_DATE('''dd'-'MM'-'yyyy HH:mm:ss''' , ''DD-MM-YYYY HH:MI:SS'')'";
logln("pattern=" + pattern); logln("pattern=" + pattern);
SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.US); SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.US);
@SuppressWarnings("deprecation")
String result = format.format(new Date(1998-1900, Calendar.JUNE, 30, 13, 30, 0)); String result = format.format(new Date(1998-1900, Calendar.JUNE, 30, 13, 30, 0));
if (!result.equals("TO_DATE('30-06-1998 13:30:00' , 'DD-MM-YYYY HH:MI:SS')")) { if (!result.equals("TO_DATE('30-06-1998 13:30:00' , 'DD-MM-YYYY HH:MI:SS')")) {
errln("Fail: result=" + result); errln("Fail: result=" + result);
@ -711,6 +719,7 @@ public class DateFormatRegression extends IntlTest {
* 'z' at end of date format throws index exception in SimpleDateFormat * 'z' at end of date format throws index exception in SimpleDateFormat
* CANNOT REPRODUCE THIS BUG ON 1.2FCS * CANNOT REPRODUCE THIS BUG ON 1.2FCS
*/ */
@SuppressWarnings("deprecation")
public void Test4151706() { public void Test4151706() {
SimpleDateFormat fmt = SimpleDateFormat fmt =
new SimpleDateFormat("EEEE, dd-MMM-yy HH:mm:ss z", Locale.US); new SimpleDateFormat("EEEE, dd-MMM-yy HH:mm:ss z", Locale.US);
@ -755,6 +764,7 @@ public class DateFormatRegression extends IntlTest {
* Confirm that "EST"(GMT-5:00) and "CST"(GMT-6:00) are used in US * Confirm that "EST"(GMT-5:00) and "CST"(GMT-6:00) are used in US
* as "EST" or "CST", not Australian "EST" and "CST". * as "EST" or "CST", not Australian "EST" and "CST".
*/ */
@SuppressWarnings("deprecation")
public void Test4406615() { public void Test4406615() {
Locale savedLocale = Locale.getDefault(); Locale savedLocale = Locale.getDefault();
TimeZone savedTimeZone = TimeZone.getDefault(); TimeZone savedTimeZone = TimeZone.getDefault();
@ -823,6 +833,7 @@ public class DateFormatRegression extends IntlTest {
* greater than "99", are treated as literal years. So "1/2/3456" * greater than "99", are treated as literal years. So "1/2/3456"
* becomes 3456 AD. Likewise, "1/2/-3" becomes -3 AD == 2 BC. * becomes 3456 AD. Likewise, "1/2/-3" becomes -3 AD == 2 BC.
*/ */
@SuppressWarnings("deprecation")
Object[] DATA = { Object[] DATA = {
"02/29/00", new Date(2000-1900, Calendar.FEBRUARY, 29), "02/29/00", new Date(2000-1900, Calendar.FEBRUARY, 29),
"01/23/01", new Date(2001-1900, Calendar.JANUARY, 23), "01/23/01", new Date(2001-1900, Calendar.JANUARY, 23),
@ -878,6 +889,7 @@ public class DateFormatRegression extends IntlTest {
DateFormat fmt = new SimpleDateFormat(pattern, DateFormat fmt = new SimpleDateFormat(pattern,
DateFormatSymbols.getInstance(Locale.US)); DateFormatSymbols.getInstance(Locale.US));
fmt.getCalendar().setLenient(false); fmt.getCalendar().setLenient(false);
@SuppressWarnings("deprecation")
Date d = new Date(2000-1900, Calendar.FEBRUARY, 29); Date d = new Date(2000-1900, Calendar.FEBRUARY, 29);
String s = fmt.format(d); String s = fmt.format(d);
logln(d + " x " + pattern + " => " + s); logln(d + " x " + pattern + " => " + s);
@ -957,6 +969,7 @@ public class DateFormatRegression extends IntlTest {
} }
} }
@SuppressWarnings("deprecation")
public void Test4253490() throws ParseException { public void Test4253490() throws ParseException {
SimpleDateFormat fmt = new SimpleDateFormat("S", Locale.US); SimpleDateFormat fmt = new SimpleDateFormat("S", Locale.US);
@ -1026,6 +1039,7 @@ public class DateFormatRegression extends IntlTest {
public void Test4250359() { public void Test4250359() {
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT, DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT,
Locale.US); Locale.US);
@SuppressWarnings("deprecation")
Date d = new Date(1999-1900, Calendar.DECEMBER, 25, Date d = new Date(1999-1900, Calendar.DECEMBER, 25,
1, 2, 3); 1, 2, 3);
String s = df.format(d); String s = df.format(d);
@ -1052,6 +1066,7 @@ public class DateFormatRegression extends IntlTest {
// pick up another time zone when L10N is done to that file. // pick up another time zone when L10N is done to that file.
TimeZone.setDefault(TimeZone.getTimeZone("PST")); TimeZone.setDefault(TimeZone.getTimeZone("PST"));
SimpleDateFormat fmt = new SimpleDateFormat("yy/MM/dd hh:ss zzz", Locale.JAPAN); SimpleDateFormat fmt = new SimpleDateFormat("yy/MM/dd hh:ss zzz", Locale.JAPAN);
@SuppressWarnings("deprecation")
String result = fmt.format(new Date(1999, 0, 1)); String result = fmt.format(new Date(1999, 0, 1));
logln("format()=>" + result); logln("format()=>" + result);
if (!result.endsWith("PST")) { if (!result.endsWith("PST")) {

View File

@ -104,7 +104,7 @@ public class DateFormatRoundTripTest extends IntlTest {
String pat = null; String pat = null;
Date date = null; Date date = null;
Vector newArgs = new Vector(); List<String> newArgs = new ArrayList<>();
for (int i=0; i<args.length; ++i) { for (int i=0; i<args.length; ++i) {
if (args[i].equals("-locale") if (args[i].equals("-locale")
&& (i+1) < args.length) { && (i+1) < args.length) {
@ -131,13 +131,13 @@ public class DateFormatRoundTripTest extends IntlTest {
seed = Long.parseLong(args[i+1]); seed = Long.parseLong(args[i+1]);
++i; ++i;
} else { } else {
newArgs.addElement(args[i]); newArgs.add(args[i]);
} }
} }
if (newArgs.size() != args.length) { if (newArgs.size() != args.length) {
args = new String[newArgs.size()]; args = new String[newArgs.size()];
newArgs.copyInto(args); newArgs.addAll(Arrays.asList(args));
} }
new DateFormatRoundTripTest(random, seed, infinite, date, pat, loc).run(args); new DateFormatRoundTripTest(random, seed, infinite, date, pat, loc).run(args);
@ -193,6 +193,7 @@ public class DateFormatRoundTripTest extends IntlTest {
* Return the Date of this test case; must be called with the default * Return the Date of this test case; must be called with the default
* zone set to this TestCase's zone. * zone set to this TestCase's zone.
*/ */
@SuppressWarnings("deprecation")
Date getDate() { Date getDate() {
if (_date == null) { if (_date == null) {
// Date constructor will work right iff we are in the target zone // Date constructor will work right iff we are in the target zone

View File

@ -29,6 +29,7 @@
*/ */
import java.text.DateFormatSymbols; import java.text.DateFormatSymbols;
@SuppressWarnings("serial")
public class DateFormatSymbolsCloneTest extends DateFormatSymbols { public class DateFormatSymbolsCloneTest extends DateFormatSymbols {
private int value; private int value;

View File

@ -36,6 +36,7 @@ import static java.util.Calendar.*;
public class NonGregorianFormatTest { public class NonGregorianFormatTest {
static int errors; static int errors;
@SuppressWarnings("deprecation")
static final Object[][] JAPANESE_EN = { static final Object[][] JAPANESE_EN = {
{ "GGGG yyyy MMMM d", "Showa 1 December 31", new Date(1926-1900, DECEMBER, 31) }, { "GGGG yyyy MMMM d", "Showa 1 December 31", new Date(1926-1900, DECEMBER, 31) },
{ "GGGG yyyy MMMM d", "Showa 64 January 6", new Date(1989-1900, JANUARY, 6) }, { "GGGG yyyy MMMM d", "Showa 64 January 6", new Date(1989-1900, JANUARY, 6) },
@ -58,6 +59,7 @@ public class NonGregorianFormatTest {
{ "Gyy.MM.dd", "H01.01.01" }, { "Gyy.MM.dd", "H01.01.01" },
}; };
@SuppressWarnings("deprecation")
static final Object[][] BUDDHIST_EN = { static final Object[][] BUDDHIST_EN = {
{ "GGGG yyyy MMMM d", "B.E. 2469 December 31", new Date(1926-1900, DECEMBER, 31) }, { "GGGG yyyy MMMM d", "B.E. 2469 December 31", new Date(1926-1900, DECEMBER, 31) },
{ "GGGG yyyy MMMM d", "B.E. 2532 January 6", new Date(1989-1900, JANUARY, 6) }, { "GGGG yyyy MMMM d", "B.E. 2532 January 6", new Date(1989-1900, JANUARY, 6) },
@ -71,6 +73,7 @@ public class NonGregorianFormatTest {
static final String FULL_DATE_FORMAT_JA = "GGGGyyyy'\u5e74'M'\u6708'd'\u65e5'"; static final String FULL_DATE_FORMAT_JA = "GGGGyyyy'\u5e74'M'\u6708'd'\u65e5'";
@SuppressWarnings("deprecation")
static final Object[][] JAPANESE_JA = { static final Object[][] JAPANESE_JA = {
{ FULL_DATE_FORMAT_JA, "\u662d\u548c\u5143\u5e7412\u670831\u65e5", new Date(1926-1900, DECEMBER, 31) }, { FULL_DATE_FORMAT_JA, "\u662d\u548c\u5143\u5e7412\u670831\u65e5", new Date(1926-1900, DECEMBER, 31) },
{ FULL_DATE_FORMAT_JA, "\u662d\u548c64\u5e741\u67086\u65e5", new Date(1989-1900, JANUARY, 6) }, { FULL_DATE_FORMAT_JA, "\u662d\u548c64\u5e741\u67086\u65e5", new Date(1989-1900, JANUARY, 6) },
@ -93,6 +96,7 @@ public class NonGregorianFormatTest {
{ "Gyy.MM.dd", "H01.01.01" }, { "Gyy.MM.dd", "H01.01.01" },
}; };
@SuppressWarnings("deprecation")
static final Object[][] BUDDHIST_JA = { static final Object[][] BUDDHIST_JA = {
{ FULL_DATE_FORMAT_JA, "\u4ecf\u66a62469\u5e7412\u670831\u65e5", new Date(1926-1900, DECEMBER, 31) }, { FULL_DATE_FORMAT_JA, "\u4ecf\u66a62469\u5e7412\u670831\u65e5", new Date(1926-1900, DECEMBER, 31) },
{ FULL_DATE_FORMAT_JA, "\u4ecf\u66a62532\u5e741\u67086\u65e5", new Date(1989-1900, JANUARY, 6) }, { FULL_DATE_FORMAT_JA, "\u4ecf\u66a62532\u5e741\u67086\u65e5", new Date(1989-1900, JANUARY, 6) },
@ -137,6 +141,7 @@ public class NonGregorianFormatTest {
locale == Locale.ENGLISH ? BUDDHIST_EN : BUDDHIST_JA); locale == Locale.ENGLISH ? BUDDHIST_EN : BUDDHIST_JA);
} }
@SuppressWarnings("deprecation")
private static void testRoundTrip(Locale calendarLocale) { private static void testRoundTrip(Locale calendarLocale) {
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL,
DateFormat.FULL, DateFormat.FULL,

View File

@ -60,6 +60,7 @@ public class bug4358730 extends IntlTest {
SimpleDateFormat sdf = new SimpleDateFormat(); SimpleDateFormat sdf = new SimpleDateFormat();
for (int i = 0; i < datasize; i++) { for (int i = 0; i < datasize; i++) {
@SuppressWarnings("deprecation")
Date d = new Date(year[i]-1900, 10, 15); Date d = new Date(year[i]-1900, 10, 15);
for (int j = 0; j < nPatterns; j++) { for (int j = 0; j < nPatterns; j++) {
sdf.applyPattern(patterns[j]); sdf.applyPattern(patterns[j]);

View File

@ -98,7 +98,7 @@ public class Bug4185816Test extends IntlTest {
final InputStream is = HexDumpReader.getStreamFromHexDump(fileName + ".txt"); final InputStream is = HexDumpReader.getStreamFromHexDump(fileName + ".txt");
final ObjectInputStream in = new ObjectInputStream(is); final ObjectInputStream in = new ObjectInputStream(is);
final MessageFormat form = (MessageFormat)in.readObject(); final MessageFormat form = (MessageFormat)in.readObject();
final Object[] testArgs = {new Long(12373), "MyDisk"}; final Object[] testArgs = {12373L, "MyDisk"};
final String result = form.format(testArgs); final String result = form.format(testArgs);
in.close(); in.close();
} catch (Exception e) { } catch (Exception e) {

View File

@ -56,18 +56,19 @@ public class LargeMessageFormat {
private static void testFormat() { private static void testFormat() {
// construct large argument array // construct large argument array
@SuppressWarnings("deprecation")
Object[] sample = { Object[] sample = {
new Integer(0), // replace with running count below 0, // replace with running count below
"hello", "hello",
new Date(89, 10, 9), new Date(89, 10, 9),
new Integer(567890), 567890,
new Double(1234.50) 1234.50
}; };
int samples = sample.length; int samples = sample.length;
Object[] arguments = new Object[REPEATS * (samples + 1)]; Object[] arguments = new Object[REPEATS * (samples + 1)];
for (int i = 0; i < REPEATS; i++) { for (int i = 0; i < REPEATS; i++) {
System.arraycopy(sample, 0, arguments, i * samples, samples); System.arraycopy(sample, 0, arguments, i * samples, samples);
arguments[i * samples] = new Integer(i); arguments[i * samples] = i;
} }
// construct large template // construct large template

View File

@ -136,7 +136,7 @@ public class MessageRegression extends IntlTest {
try { try {
logln("Apply with pattern : " + pattern1); logln("Apply with pattern : " + pattern1);
messageFormatter.applyPattern(pattern1); messageFormatter.applyPattern(pattern1);
Object[] params = {new Integer(7)}; Object[] params = {7};
String tempBuffer = messageFormatter.format(params); String tempBuffer = messageFormatter.format(params);
if (!tempBuffer.equals("Impossible {1} has occurred -- status code is 7 and message is {2}.")) if (!tempBuffer.equals("Impossible {1} has occurred -- status code is 7 and message is {2}."))
errln("Tests arguments < substitution failed. Formatted text=" + errln("Tests arguments < substitution failed. Formatted text=" +
@ -455,7 +455,7 @@ public class MessageRegression extends IntlTest {
errln("argument0: \"" + objs[0] + "\""); errln("argument0: \"" + objs[0] + "\"");
mf.setLocale(Locale.US); mf.setLocale(Locale.US);
mf.applyPattern("{0,number,#.##}, {0,number,#.#}"); mf.applyPattern("{0,number,#.##}, {0,number,#.#}");
Object[] oldobjs = {new Double(3.1415)}; Object[] oldobjs = {3.1415};
String result = mf.format( oldobjs ); String result = mf.format( oldobjs );
logln("pattern: \"" + mf.toPattern() + "\""); logln("pattern: \"" + mf.toPattern() + "\"");
logln("text for parsing: \"" + result + "\""); logln("text for parsing: \"" + result + "\"");
@ -481,7 +481,7 @@ public class MessageRegression extends IntlTest {
ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart); ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
form1.setFormat(1, fileform); form1.setFormat(1, fileform);
form2.setFormat(0, fileform); form2.setFormat(0, fileform);
Object[] testArgs = {new Long(12373), "MyDisk"}; Object[] testArgs = {12373L, "MyDisk"};
logln(form1.format(testArgs)); logln(form1.format(testArgs));
logln(form2.format(testArgs)); logln(form2.format(testArgs));
} }
@ -531,7 +531,7 @@ public class MessageRegression extends IntlTest {
}; };
for (int i=0; i<3; i++) { for (int i=0; i<3; i++) {
String out = mf.format(new Object[]{new Integer(i)}); String out = mf.format(new Object[]{i});
if (SUFFIX[i] == null) { if (SUFFIX[i] == null) {
if (!out.equals(PREFIX[i])) if (!out.equals(PREFIX[i]))
errln("" + i + ": Got \"" + out + "\"; Want \"" + PREFIX[i] + "\""); errln("" + i + ": Got \"" + out + "\"; Want \"" + PREFIX[i] + "\"");
@ -607,8 +607,7 @@ public class MessageRegression extends IntlTest {
*/ */
public void Test4169959() { public void Test4169959() {
// This works // This works
logln(MessageFormat.format( "This will {0}", logln(MessageFormat.format( "This will {0}", "work"));
new String[]{"work"} ) );
// This fails // This fails
logln(MessageFormat.format( "This will {0}", logln(MessageFormat.format( "This will {0}",

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -52,7 +52,7 @@ public class MessageTest extends IntlTest {
public void TestMSGPatternTest() { public void TestMSGPatternTest() {
Object[] testArgs = { Object[] testArgs = {
new Double (1), new Double(3456), 1D, 3456D,
"Disk", new Date(10000000000L)}; "Disk", new Date(10000000000L)};
String[] testCases = { String[] testCases = {

View File

@ -118,7 +118,7 @@ public class BigDecimalCompatibilityTest {
bd = bd.divide(new BigDecimal(multiplier)); bd = bd.divide(new BigDecimal(multiplier));
} }
catch (ArithmeticException e) { catch (ArithmeticException e) {
bd = bd.divide(new BigDecimal(multiplier), BigDecimal.ROUND_HALF_EVEN); bd = bd.divide(new BigDecimal(multiplier), RoundingMode.HALF_EVEN);
} }
check(num, bd, multiplier); check(num, bd, multiplier);
} }

View File

@ -793,7 +793,7 @@ public class BigDecimalFormat extends IntlTest {
formatted.setLength(0); formatted.setLength(0);
from = "123456789"; from = "123456789";
to = sep_zero.substring(0, 399) + ",123,456,789"; to = sep_zero.substring(0, 399) + ",123,456,789";
nf.format(new Long(from), formatted, new FieldPosition(0)); nf.format(123456789L, formatted, new FieldPosition(0));
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier()); checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
@ -810,7 +810,7 @@ public class BigDecimalFormat extends IntlTest {
from = "123456789"; from = "123456789";
to = "-" + nonsep_zero.substring(0, 300) + "123456789." + to = "-" + nonsep_zero.substring(0, 300) + "123456789." +
nonsep_zero.substring(0, 340); nonsep_zero.substring(0, 340);
nf.format(new Long(from), formatted, new FieldPosition(0)); nf.format(123456789L, formatted, new FieldPosition(0));
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier()); checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
@ -827,7 +827,7 @@ public class BigDecimalFormat extends IntlTest {
from = Long.toString(Long.MAX_VALUE); from = Long.toString(Long.MAX_VALUE);
to = sep_zero.substring(0, 373) + to = sep_zero.substring(0, 373) +
"19,807,040,619,342,712,359,383,728,129"; "19,807,040,619,342,712,359,383,728,129";
nf.format(new Long(from), formatted, new FieldPosition(0)); nf.format(Long.MAX_VALUE, formatted, new FieldPosition(0));
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier()); checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
@ -844,7 +844,7 @@ public class BigDecimalFormat extends IntlTest {
from = Long.toString(Long.MAX_VALUE); from = Long.toString(Long.MAX_VALUE);
to = "-1.9807040628566084396238503936" + to = "-1.9807040628566084396238503936" +
nonsep_zero.substring(0, 312) + "E28"; nonsep_zero.substring(0, 312) + "E28";
nf.format(new Long(from), formatted, new FieldPosition(0)); nf.format(Long.MAX_VALUE, formatted, new FieldPosition(0));
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier()); checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
@ -862,7 +862,7 @@ public class BigDecimalFormat extends IntlTest {
to = "-19807040619342712361531211776" + to = "-19807040619342712361531211776" +
nonsep_zero.substring(0, 280) + "." + nonsep_zero.substring(0, 280) + "." +
nonsep_zero.substring(0, 340) + "E-280"; nonsep_zero.substring(0, 340) + "E-280";
nf.format(new Long(from), formatted, new FieldPosition(0)); nf.format(Long.MIN_VALUE, formatted, new FieldPosition(0));
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier()); checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
@ -880,7 +880,7 @@ public class BigDecimalFormat extends IntlTest {
to = sep_zero.substring(0, 373) + to = sep_zero.substring(0, 373) +
"19,807,040,628,566,084,398,385,987,584." + "19,807,040,628,566,084,398,385,987,584." +
nonsep_zero.substring(0, 340); nonsep_zero.substring(0, 340);
nf.format(new Long(from), formatted, new FieldPosition(0)); nf.format(Long.MIN_VALUE, formatted, new FieldPosition(0));
checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier()); checkFormat(from, formatted, to, ((DecimalFormat)nf).getMultiplier());
} }

View File

@ -199,15 +199,15 @@ public class BigDecimalParse extends IntlTest {
// From: 1000.000 // From: 1000.000
// To: Double.POSITIVE_INFINITY // To: Double.POSITIVE_INFINITY
check("1000.000", new Double(Double.POSITIVE_INFINITY)); check("1000.000", Double.POSITIVE_INFINITY);
// From: -1000 // From: -1000
// To: Double.NEGATIVE_INFINITY // To: Double.NEGATIVE_INFINITY
check("-1000", new Double(Double.NEGATIVE_INFINITY)); check("-1000", Double.NEGATIVE_INFINITY);
// From: -0.00 // From: -0.00
// To: Double.NaN // To: Double.NaN
check("-0.00", new Double(Double.NaN)); check("-0.00", Double.NaN);
} }
/** /**
@ -220,31 +220,31 @@ public class BigDecimalParse extends IntlTest {
// From: 1000.000 // From: 1000.000
// To: Double.POSITIVE_INFINITY // To: Double.POSITIVE_INFINITY
check("1000.000", new Double(Double.POSITIVE_INFINITY)); check("1000.000", Double.POSITIVE_INFINITY);
// From: -1000.000 // From: -1000.000
// To: Double.NEGATIVE_INFINITY // To: Double.NEGATIVE_INFINITY
check("-1000.000", new Double(Double.NEGATIVE_INFINITY)); check("-1000.000", Double.NEGATIVE_INFINITY);
// From: 0.0 // From: 0.0
// To: Double.NaN // To: Double.NaN
check("0.0", new Double(Double.NaN)); check("0.0", Double.NaN);
// From: -0.0 (Double) // From: -0.0 (Double)
// To: Double.NaN // To: Double.NaN
check("-0.0", new Double(Double.NaN)); check("-0.0", Double.NaN);
// From: Double.NaN // From: Double.NaN
// To: Double.NaN // To: Double.NaN
check("\ufffd", new Double(Double.NaN)); check("\ufffd", Double.NaN);
// From: Double.POSITIVE_INFINITY // From: Double.POSITIVE_INFINITY
// To: Double.NaN // To: Double.NaN
check("\u221e", new Double(Double.POSITIVE_INFINITY)); check("\u221e", Double.POSITIVE_INFINITY);
// From: Double.NEGATIVE_INFINITY // From: Double.NEGATIVE_INFINITY
// To: Double.NaN // To: Double.NaN
check("-\u221e", new Double(Double.NEGATIVE_INFINITY)); check("-\u221e", Double.NEGATIVE_INFINITY);
} }
/** /**
@ -257,15 +257,15 @@ public class BigDecimalParse extends IntlTest {
// From: 1000 // From: 1000
// To: Double.POSITIVE_INFINITY // To: Double.POSITIVE_INFINITY
check("1000", new Double(Double.POSITIVE_INFINITY)); check("1000", Double.POSITIVE_INFINITY);
// From: -1000 // From: -1000
// To: Double.NEGATIVE_INFINITY // To: Double.NEGATIVE_INFINITY
check("-1000", new Double(Double.NEGATIVE_INFINITY)); check("-1000", Double.NEGATIVE_INFINITY);
// From: -000 (Long) // From: -000 (Long)
// To: Double.NaN // To: Double.NaN
check("-000", new Double(Double.NaN)); check("-000", Double.NaN);
} }
/** /**
@ -350,20 +350,20 @@ public class BigDecimalParse extends IntlTest {
{ {
new BigDecimal("0"), new BigDecimal("0.0"), new BigDecimal("5"), new BigDecimal("0"), new BigDecimal("0.0"), new BigDecimal("5"),
new BigDecimal("5.0"), new BigDecimal("5.1"), new BigDecimal("5.0"), new BigDecimal("5.1"),
new Double(Double.POSITIVE_INFINITY), new Double(Double.NaN), Double.POSITIVE_INFINITY, Double.NaN,
new BigDecimal("0"), new BigDecimal("0.0"), new BigDecimal("0"), new BigDecimal("0.0"),
new BigDecimal("-5"), new BigDecimal("-5.0"), new BigDecimal("-5"), new BigDecimal("-5.0"),
new BigDecimal("-5.1"), new BigDecimal("-5.1"),
new Double(Double.NEGATIVE_INFINITY), new Double(Double.NaN), Double.NEGATIVE_INFINITY, Double.NaN,
}, },
{ {
new BigDecimal("0"), new BigDecimal("0.0"), new BigDecimal("0"), new BigDecimal("0.0"),
new BigDecimal("-5"), new BigDecimal("-5.0"), new BigDecimal("-5"), new BigDecimal("-5.0"),
new BigDecimal("-5.1"), new BigDecimal("-5.1"),
new Double(Double.NEGATIVE_INFINITY), new Double(Double.NaN), Double.NEGATIVE_INFINITY, Double.NaN,
new BigDecimal("0"), new BigDecimal("0.0"), new BigDecimal("5"), new BigDecimal("0"), new BigDecimal("0.0"), new BigDecimal("5"),
new BigDecimal("5.0"), new BigDecimal("5.1"), new BigDecimal("5.0"), new BigDecimal("5.1"),
new Double(Double.POSITIVE_INFINITY), Double.POSITIVE_INFINITY,
}, },
}; };

View File

@ -47,12 +47,12 @@ public class Bug4208135 {
df.applyPattern("0.#E0"); df.applyPattern("0.#E0");
df.setDecimalSeparatorAlwaysShown(true); df.setDecimalSeparatorAlwaysShown(true);
checkFormat(new Double(0.0), "0.E0"); checkFormat(0.0, "0.E0");
checkFormat(new Double(10.0), "1.E1"); checkFormat(10.0, "1.E1");
checkFormat(new Double(1000.0), "1.E3"); checkFormat(1000.0, "1.E3");
checkFormat(new Long(0), "0.E0"); checkFormat(0L, "0.E0");
checkFormat(new Long(10), "1.E1"); checkFormat(10L, "1.E1");
checkFormat(new Long(1000), "1.E3"); checkFormat(1000L, "1.E3");
checkFormat(new BigDecimal("0.0"), "0.E0"); checkFormat(new BigDecimal("0.0"), "0.E0");
checkFormat(new BigDecimal("10.0"), "1.E1"); checkFormat(new BigDecimal("10.0"), "1.E1");
checkFormat(new BigDecimal("1000.0"), "1.E3"); checkFormat(new BigDecimal("1000.0"), "1.E3");
@ -61,12 +61,12 @@ public class Bug4208135 {
checkFormat(new BigInteger("1000"), "1.E3"); checkFormat(new BigInteger("1000"), "1.E3");
df.setDecimalSeparatorAlwaysShown(false); df.setDecimalSeparatorAlwaysShown(false);
checkFormat(new Double(0.0), "0E0"); checkFormat(0.0, "0E0");
checkFormat(new Double(10.0), "1E1"); checkFormat(10.0, "1E1");
checkFormat(new Double(1000.0), "1E3"); checkFormat(1000.0, "1E3");
checkFormat(new Long(0), "0E0"); checkFormat(0L, "0E0");
checkFormat(new Long(10), "1E1"); checkFormat(10L, "1E1");
checkFormat(new Long(1000), "1E3"); checkFormat(1000L, "1E3");
checkFormat(new BigDecimal("0.0"), "0E0"); checkFormat(new BigDecimal("0.0"), "0E0");
checkFormat(new BigDecimal("10.0"), "1E1"); checkFormat(new BigDecimal("10.0"), "1E1");
checkFormat(new BigDecimal("1000.0"), "1E3"); checkFormat(new BigDecimal("1000.0"), "1E3");
@ -77,12 +77,12 @@ public class Bug4208135 {
df.applyPattern("0.###"); df.applyPattern("0.###");
df.setDecimalSeparatorAlwaysShown(true); df.setDecimalSeparatorAlwaysShown(true);
checkFormat(new Double(0.0), "0."); checkFormat(0.0, "0.");
checkFormat(new Double(10.0), "10."); checkFormat(10.0, "10.");
checkFormat(new Double(1000.0), "1000."); checkFormat(1000.0, "1000.");
checkFormat(new Long(0), "0."); checkFormat(0L, "0.");
checkFormat(new Long(10), "10."); checkFormat(10L, "10.");
checkFormat(new Long(1000), "1000."); checkFormat(1000L, "1000.");
checkFormat(new BigDecimal("0.0"), "0."); checkFormat(new BigDecimal("0.0"), "0.");
checkFormat(new BigDecimal("10.0"), "10."); checkFormat(new BigDecimal("10.0"), "10.");
checkFormat(new BigDecimal("1000.0"), "1000."); checkFormat(new BigDecimal("1000.0"), "1000.");
@ -91,12 +91,12 @@ public class Bug4208135 {
checkFormat(new BigInteger("1000"), "1000."); checkFormat(new BigInteger("1000"), "1000.");
df.setDecimalSeparatorAlwaysShown(false); df.setDecimalSeparatorAlwaysShown(false);
checkFormat(new Double(0.0), "0"); checkFormat(0.0, "0");
checkFormat(new Double(10.0), "10"); checkFormat(10.0, "10");
checkFormat(new Double(1000.0), "1000"); checkFormat(1000.0, "1000");
checkFormat(new Long(0), "0"); checkFormat(0L, "0");
checkFormat(new Long(10), "10"); checkFormat(10L, "10");
checkFormat(new Long(1000), "1000"); checkFormat(1000L, "1000");
checkFormat(new BigDecimal("0.0"), "0"); checkFormat(new BigDecimal("0.0"), "0");
checkFormat(new BigDecimal("10.0"), "10"); checkFormat(new BigDecimal("10.0"), "10");
checkFormat(new BigDecimal("1000.0"), "1000"); checkFormat(new BigDecimal("1000.0"), "1000");

View File

@ -51,20 +51,20 @@ public class Bug4833877 {
/* /*
* Test for double/Double * Test for double/Double
*/ */
checkFormat(new Double(252.5252525252525), "1,010.10101010101"); checkFormat(252.5252525252525, "1,010.10101010101");
checkParse("-1,010.10101010101", new Double(-252.5252525252525)); checkParse("-1,010.10101010101", -252.5252525252525);
checkFormat(new Double(-2222.2222), "-8,888.8888"); checkFormat(-2222.2222, "-8,888.8888");
checkParse("8888.8888", new Double(2222.2222)); checkParse("8888.8888", 2222.2222);
/* /*
* Test for long/Long * Test for long/Long
*/ */
checkFormat(new Long(1000), "4,000"); checkFormat(1000L, "4,000");
checkParse("-4,000", new Long(-1000)); checkParse("-4,000", -1000L);
checkFormat(new Long(-250), "-1,000"); checkFormat(-250L, "-1,000");
checkParse("1000", new Long(250)); checkParse("1000", 250L);
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
@ -104,20 +104,20 @@ public class Bug4833877 {
/* /*
* Test for double/Double * Test for double/Double
*/ */
checkFormat(new Double(252.5252525252525), "-1,010.10101010101"); checkFormat(252.5252525252525, "-1,010.10101010101");
checkParse("-1,010.10101010101", new Double(252.5252525252525)); checkParse("-1,010.10101010101", 252.5252525252525);
checkFormat(new Double(-2222.2222), "8,888.8888"); checkFormat(-2222.2222, "8,888.8888");
checkParse("8888.8888", new Double(-2222.2222)); checkParse("8888.8888", -2222.2222);
/* /*
* Test for long/Long * Test for long/Long
*/ */
checkFormat(new Long(1000), "-4,000"); checkFormat(1000L, "-4,000");
checkParse("-4,000", new Long(1000)); checkParse("-4,000", 1000L);
checkFormat(new Long(-250), "1,000"); checkFormat(-250L, "1,000");
checkParse("1000", new Long(-250)); checkParse("1000", -250L);
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
@ -157,30 +157,30 @@ public class Bug4833877 {
/* /*
* Test for double/Double * Test for double/Double
*/ */
checkFormat(new Double(3333.3333333), "-9,999.9999999"); checkFormat(3333.3333333, "-9,999.9999999");
checkParse("-10,000.00000000000", new Double(3333.3333333333335));// rounding error checkParse("-10,000.00000000000", 3333.3333333333335);// rounding error
df.setParseIntegerOnly(true); df.setParseIntegerOnly(true);
checkFormat(new Double(-3333.3333333), "9,999.9999999"); checkFormat(-3333.3333333, "9,999.9999999");
checkParse("10,000.00000000000", new Long(-3333)); checkParse("10,000.00000000000", -3333L);
df.setParseIntegerOnly(false); df.setParseIntegerOnly(false);
checkFormat(new Double(-3333.3333333), "9,999.9999999"); checkFormat(-3333.3333333, "9,999.9999999");
checkParse("10,000.00000000000", new Double(-3333.3333333333335));// rounding error checkParse("10,000.00000000000", -3333.3333333333335);// rounding error
/* /*
* Test for long/Long * Test for long/Long
*/ */
checkFormat(new Long(3333), "-9,999"); checkFormat(3333L, "-9,999");
df.setParseIntegerOnly(true); df.setParseIntegerOnly(true);
checkParse("-10,000", new Long(3333)); checkParse("-10,000", 3333L);
df.setParseIntegerOnly(false); df.setParseIntegerOnly(false);
checkParse("-10000", new Double(3333.3333333333335));// rounding error checkParse("-10000", 3333.3333333333335);// rounding error
checkFormat(new Long(-3333), "9,999"); checkFormat(-3333L, "9,999");
df.setParseIntegerOnly(true); df.setParseIntegerOnly(true);
checkParse("10,000", new Long(-3333)); checkParse("10,000", -3333L);
df.setParseIntegerOnly(false); df.setParseIntegerOnly(false);
checkParse("10000", new Double(-3333.3333333333335));// rounding error checkParse("10000", -3333.3333333333335);// rounding error
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
@ -225,20 +225,20 @@ public class Bug4833877 {
/* /*
* Test for double/Double * Test for double/Double
*/ */
checkFormat(new Double(252.5252525252525), "1.01010101010101E3"); checkFormat(252.5252525252525, "1.01010101010101E3");
checkParse("-1.01010101010101E3", new Double(-2.525252525252525E2)); checkParse("-1.01010101010101E3", -2.525252525252525E2);
checkFormat(new Double(-2222.2222), "-8.8888888E3"); checkFormat(-2222.2222, "-8.8888888E3");
checkParse("8888.8888", new Double(2.2222222E3)); checkParse("8888.8888", 2.2222222E3);
/* /*
* Test for long/Long * Test for long/Long
*/ */
checkFormat(new Long(1000), "4E3"); checkFormat(1000L, "4E3");
checkParse("-4E3", new Long(-1000)); checkParse("-4E3", -1000L);
checkFormat(new Long(-250), "-1E3"); checkFormat(-250L, "-1E3");
checkParse("1000", new Long(250)); checkParse("1000", 250L);
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
@ -279,20 +279,20 @@ public class Bug4833877 {
/* /*
* Test for double/Double * Test for double/Double
*/ */
checkFormat(new Double(252.5252525252525), "-1.01010101010101E3"); checkFormat(252.5252525252525, "-1.01010101010101E3");
checkParse("-1.01010101010101E3", new Double(2.525252525252525E2)); checkParse("-1.01010101010101E3", 2.525252525252525E2);
checkFormat(new Double(-2222.2222), "8.8888888E3"); checkFormat(-2222.2222, "8.8888888E3");
checkParse("8888.8888", new Double(-2.2222222E3)); checkParse("8888.8888", -2.2222222E3);
/* /*
* Test for long/Long * Test for long/Long
*/ */
checkFormat(new Long(1000), "-4E3"); checkFormat(1000L, "-4E3");
checkParse("-4E3", new Long(1000)); checkParse("-4E3", 1000L);
checkFormat(new Long(-250), "1E3"); checkFormat(-250L, "1E3");
checkParse("1000", new Long(-250)); checkParse("1000", -250L);
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
@ -333,30 +333,30 @@ public class Bug4833877 {
/* /*
* Test for double/Double * Test for double/Double
*/ */
checkFormat(new Double(3333.3333333), "-9.9999999999E3"); checkFormat(3333.3333333, "-9.9999999999E3");
checkParse("-1.00000000000000E3", new Double(3.33333333333333333E2)); checkParse("-1.00000000000000E3", 3.33333333333333333E2);
df.setParseIntegerOnly(true); df.setParseIntegerOnly(true);
checkFormat(new Double(-3333.3333333), "9.9999999999E3"); checkFormat(-3333.3333333, "9.9999999999E3");
checkParse("10.00000000000000E3", new Long(-3)); checkParse("10.00000000000000E3",-3L);
df.setParseIntegerOnly(false); df.setParseIntegerOnly(false);
checkFormat(new Double(-3333.3333333), "9.9999999999E3"); checkFormat(-3333.3333333, "9.9999999999E3");
checkParse("10.00000000000000E3", new Double(-3.33333333333333333E3)); checkParse("10.00000000000000E3", -3.33333333333333333E3);
/* /*
* Test for long/Long * Test for long/Long
*/ */
checkFormat(new Long(3333), "-9.999E3"); checkFormat(3333L, "-9.999E3");
df.setParseIntegerOnly(true); df.setParseIntegerOnly(true);
checkParse("-1.0E4", new Long(0)); checkParse("-1.0E4", 0L);
df.setParseIntegerOnly(false); df.setParseIntegerOnly(false);
checkParse("-1.0E4", new Double(3333.3333333333335)); checkParse("-1.0E4", 3333.3333333333335);
checkFormat(new Long(-3333), "9.999E3"); checkFormat(-3333L, "9.999E3");
df.setParseIntegerOnly(true); df.setParseIntegerOnly(true);
checkParse("10.0E4", new Long(-3)); checkParse("10.0E4", -3L);
df.setParseIntegerOnly(false); df.setParseIntegerOnly(false);
checkParse("10.0E4", new Double(-33333.3333333333336)); checkParse("10.0E4", -33333.3333333333336);
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */

View File

@ -71,47 +71,47 @@ public class Bug4838107 extends IntlTest {
dfs = df.getDecimalFormatSymbols(); dfs = df.getDecimalFormatSymbols();
/* Test with default pattern */ /* Test with default pattern */
test(new Double(1234), "1,234"); test(1234D, "1,234");
test(new Double(0.1234), "0.123"); // rounded test(0.1234, "0.123"); // rounded
test(new Double(-1234), "-1,234"); test(-1234D, "-1,234");
test(new Double(-0.1234), "-0.123"); // rounded test(-0.1234, "-0.123"); // rounded
test(new Double(Double.POSITIVE_INFINITY), "\u221e"); test(Double.POSITIVE_INFINITY, "\u221e");
test(new Double(Double.NEGATIVE_INFINITY), "-\u221e"); test(Double.NEGATIVE_INFINITY, "-\u221e");
test(new Double(Double.NaN), "\ufffd"); // without prefix and suffix test(Double.NaN, "\ufffd"); // without prefix and suffix
test(new Double(0.0), "0"); test(0.0, "0");
test(new Double(-0.0), "-0"); // with the minus sign test(-0.0, "-0"); // with the minus sign
/* Specify a pattern and the minus sign. */ /* Specify a pattern and the minus sign. */
prepareFormatter("<P>#.###E00<S>", 'm'); prepareFormatter("<P>#.###E00<S>", 'm');
test(new Double(1234), "<P>1.234E03<S>"); test(1234D, "<P>1.234E03<S>");
test(new Double(0.1234), "<P>1.234Em01<S>"); test(0.1234, "<P>1.234Em01<S>");
test(new Double(-1234), "m<P>1.234E03<S>"); test(-1234D, "m<P>1.234E03<S>");
test(new Double(-0.1234), "m<P>1.234Em01<S>"); test(-0.1234, "m<P>1.234Em01<S>");
prepareFormatter("<P>#.###E00<S>;#.###E00", 'm'); prepareFormatter("<P>#.###E00<S>;#.###E00", 'm');
test(new Double(1234), "<P>1.234E03<S>"); test(1234D, "<P>1.234E03<S>");
test(new Double(0.1234), "<P>1.234Em01<S>"); test(0.1234, "<P>1.234Em01<S>");
test(new Double(-1234), "1.234E03"); test(-1234D, "1.234E03");
test(new Double(-0.1234), "1.234Em01"); test(-0.1234, "1.234Em01");
prepareFormatter("#.###E00;<P>#.###E00<S>", 'm'); prepareFormatter("#.###E00;<P>#.###E00<S>", 'm');
test(new Double(1234), "1.234E03"); test(1234D, "1.234E03");
test(new Double(0.1234), "1.234Em01"); test(0.1234, "1.234Em01");
test(new Double(-1234), "<P>1.234E03<S>"); test(-1234D, "<P>1.234E03<S>");
test(new Double(-0.1234), "<P>1.234Em01<S>"); test(-0.1234, "<P>1.234Em01<S>");
prepareFormatter("<P>#.###E00<S>;<p>-#.###E00<s>", 'm'); prepareFormatter("<P>#.###E00<S>;<p>-#.###E00<s>", 'm');
test(new Double(1234), "<P>1.234E03<S>"); test(1234D, "<P>1.234E03<S>");
test(new Double(0.1234), "<P>1.234Em01<S>"); test(0.1234, "<P>1.234Em01<S>");
test(new Double(-1234), "<p>m1.234E03<s>"); test(-1234D, "<p>m1.234E03<s>");
test(new Double(-0.1234), "<p>m1.234Em01<s>"); test(-0.1234, "<p>m1.234Em01<s>");
test(new Double(Double.POSITIVE_INFINITY), "<P>\u221e<S>"); test(Double.POSITIVE_INFINITY, "<P>\u221e<S>");
test(new Double(Double.NEGATIVE_INFINITY), "<p>m\u221e<s>"); test(Double.NEGATIVE_INFINITY, "<p>m\u221e<s>");
test(new Double(Double.NaN), "\ufffd"); // without prefix and suffix test(Double.NaN, "\ufffd"); // without prefix and suffix
test(new Double(0.0), "<P>0E00<S>"); test(0.0, "<P>0E00<S>");
test(new Double(-0.0), "<p>m0E00<s>"); // with the minus sign test(-0.0, "<p>m0E00<s>"); // with the minus sign
} }
static void test_BigDecimal() { static void test_BigDecimal() {
@ -151,19 +151,19 @@ public class Bug4838107 extends IntlTest {
dfs = df.getDecimalFormatSymbols(); dfs = df.getDecimalFormatSymbols();
/* Test with default pattern */ /* Test with default pattern */
test(new Long(123456789), "123,456,789"); test(123456789L, "123,456,789");
test(new Long(-123456789), "-123,456,789"); test(-123456789L, "-123,456,789");
test(new Long(0), "0"); test(0L, "0");
test(new Long(-0), "0"); test(-0L, "0");
/* Specify a pattern and the minus sign. */ /* Specify a pattern and the minus sign. */
prepareFormatter("<P>#,###<S>;<p>-#,###<s>", 'm'); prepareFormatter("<P>#,###<S>;<p>-#,###<s>", 'm');
test(new Long(123456789), "<P>123,456,789<S>"); test(123456789L, "<P>123,456,789<S>");
test(new Long(-123456789), "<p>m123,456,789<s>"); test(-123456789L, "<p>m123,456,789<s>");
test(new Long(0), "<P>0<S>"); test(0L, "<P>0<S>");
test(new Long(-0), "<P>0<S>"); test(-0L, "<P>0<S>");
} }
static void test_BigInteger() { static void test_BigInteger() {

View File

@ -84,7 +84,7 @@ public class Bug4944439 {
} }
int index = s.indexOf('.'); int index = s.indexOf('.');
Long l = new Long(s.substring(0, index)); Long l = Long.valueOf(s.substring(0, index));
if (!l.equals(number)) { if (!l.equals(number)) {
err = true; err = true;
System.err.println("Failed: DecimalFormat.parse(" + s + System.err.println("Failed: DecimalFormat.parse(" + s +
@ -101,7 +101,7 @@ public class Bug4944439 {
number.getClass().getName()); number.getClass().getName());
} }
Double d = new Double(s); Double d = Double.valueOf(s);
if (!d.equals(number)) { if (!d.equals(number)) {
err = true; err = true;
System.err.println("Failed: DecimalFormat.parse(" + s + System.err.println("Failed: DecimalFormat.parse(" + s +

View File

@ -35,6 +35,7 @@ public class Bug4990596 {
new DecimalFormat().format(new MutableInteger(0)); new DecimalFormat().format(new MutableInteger(0));
} }
@SuppressWarnings("serial")
public static class MutableInteger extends Number { public static class MutableInteger extends Number {
public int value; public int value;

View File

@ -47,7 +47,7 @@ public class Bug6278616 {
NumberFormat nf = NumberFormat.getInstance(); NumberFormat nf = NumberFormat.getInstance();
for (int j = 0; j < ints.length; j++) { for (int j = 0; j < ints.length; j++) {
String s_i = nf.format(new Integer(ints[j])); String s_i = nf.format(ints[j]);
String s_ai = nf.format(new AtomicInteger(ints[j])); String s_ai = nf.format(new AtomicInteger(ints[j]));
if (!s_i.equals(s_ai)) { if (!s_i.equals(s_ai)) {
throw new RuntimeException("format(AtomicInteger " + s_ai + throw new RuntimeException("format(AtomicInteger " + s_ai +
@ -57,7 +57,7 @@ public class Bug6278616 {
} }
for (int j = 0; j < longs.length; j++) { for (int j = 0; j < longs.length; j++) {
String s_l = nf.format(new Long(longs[j])); String s_l = nf.format(longs[j]);
String s_al = nf.format(new AtomicLong(longs[j])); String s_al = nf.format(new AtomicLong(longs[j]));
if (!s_l.equals(s_al)) { if (!s_l.equals(s_al)) {
throw new RuntimeException("format(AtomicLong " + s_al + throw new RuntimeException("format(AtomicLong " + s_al +

View File

@ -289,7 +289,7 @@ public class NumberRegression extends IntlTest {
DecimalFormat df = new DecimalFormat(); DecimalFormat df = new DecimalFormat();
Double d = (Double)df.parse("123.55456", pos=new ParsePosition(0)); Double d = (Double)df.parse("123.55456", pos=new ParsePosition(0));
if (!d.toString().equals("123.55456")) { if (!d.toString().equals("123.55456")) {
errln("Result -> " + d.doubleValue()); errln("Result -> " + d);
} }
Locale.setDefault(savedLocale); Locale.setDefault(savedLocale);
} }
@ -395,11 +395,11 @@ public class NumberRegression extends IntlTest {
Locale.setDefault(Locale.US); Locale.setDefault(Locale.US);
DecimalFormat df = new DecimalFormat(); DecimalFormat df = new DecimalFormat();
String str = "0.1234"; String str = "0.1234";
Double d1 = new Double(str); Double d1 = 0.1234;
Double d2 = (Double) df.parse(str, new ParsePosition(0)); Double d2 = (Double) df.parse(str, new ParsePosition(0));
logln(d1.toString()); logln(d1.toString());
if (d2.doubleValue() != d1.doubleValue()) if (d2.doubleValue() != d1.doubleValue())
errln("Bug 4095713 test failed, new double value : " + d2.doubleValue()); errln("Bug 4095713 test failed, new double value : " + d2);
Locale.setDefault(savedLocale); Locale.setDefault(savedLocale);
} }
@ -870,7 +870,7 @@ public class NumberRegression extends IntlTest {
DecimalFormat fmt = new DecimalFormat("#,##0.00"); DecimalFormat fmt = new DecimalFormat("#,##0.00");
StringBuffer formatted = new StringBuffer(); StringBuffer formatted = new StringBuffer();
FieldPosition field = new FieldPosition(0); FieldPosition field = new FieldPosition(0);
Double num = new Double(1234.5); Double num = 1234.5;
fmt.format(num, formatted, field); fmt.format(num, formatted, field);
if (field.getBeginIndex() != 0 && field.getEndIndex() != 5) if (field.getBeginIndex() != 0 && field.getEndIndex() != 5)
errln("Format 1234.5 failed. Begin index: " + field.getBeginIndex() + " End index: " + field.getEndIndex()); errln("Format 1234.5 failed. Begin index: " + field.getBeginIndex() + " End index: " + field.getEndIndex());
@ -1416,7 +1416,7 @@ public class NumberRegression extends IntlTest {
DecimalFormat fmt = new DecimalFormat("#", DecimalFormat fmt = new DecimalFormat("#",
DecimalFormatSymbols.getInstance(Locale.US)); DecimalFormatSymbols.getInstance(Locale.US));
for (int i=0; i<DATA.length; i+=3) { for (int i=0; i<DATA.length; i+=3) {
double in = Double.valueOf(DATA[i]).doubleValue(); double in = Double.valueOf(DATA[i]);
String pat = DATA[i+1]; String pat = DATA[i+1];
String exp = DATA[i+2]; String exp = DATA[i+2];
fmt.applyPattern(pat); fmt.applyPattern(pat);
@ -1622,7 +1622,7 @@ public class NumberRegression extends IntlTest {
String str = Long.toString(DATA[i]); String str = Long.toString(DATA[i]);
for (int m = 1; m <= 100; m++) { for (int m = 1; m <= 100; m++) {
fmt.setMultiplier(m); fmt.setMultiplier(m);
long n = ((Number) fmt.parse(str)).longValue(); long n = fmt.parse(str).longValue();
if (n > 0 != DATA[i] > 0) { if (n > 0 != DATA[i] > 0) {
errln("\"" + str + "\" parse(x " + fmt.getMultiplier() + errln("\"" + str + "\" parse(x " + fmt.getMultiplier() +
") => " + n); ") => " + n);
@ -1637,15 +1637,15 @@ public class NumberRegression extends IntlTest {
*/ */
public void Test4217661() { public void Test4217661() {
Object[] DATA = { Object[] DATA = {
new Double(0.001), "0", 0.001, "0",
new Double(1.001), "1", 1.001, "1",
new Double(0.006), "0.01", 0.006, "0.01",
new Double(1.006), "1.01", 1.006, "1.01",
}; };
NumberFormat fmt = NumberFormat.getInstance(Locale.US); NumberFormat fmt = NumberFormat.getInstance(Locale.US);
fmt.setMaximumFractionDigits(2); fmt.setMaximumFractionDigits(2);
for (int i=0; i<DATA.length; i+=2) { for (int i=0; i<DATA.length; i+=2) {
String s = fmt.format(((Double) DATA[i]).doubleValue()); String s = fmt.format((Double) DATA[i]);
if (!s.equals(DATA[i+1])) { if (!s.equals(DATA[i+1])) {
errln("FAIL: Got " + s + ", exp " + DATA[i+1]); errln("FAIL: Got " + s + ", exp " + DATA[i+1]);
} }
@ -1804,6 +1804,7 @@ public class NumberRegression extends IntlTest {
} }
} }
@SuppressWarnings("serial")
class myformat implements Serializable class myformat implements Serializable
{ {
DateFormat _dateFormat = DateFormat.getDateInstance(); DateFormat _dateFormat = DateFormat.getDateInstance();
@ -1817,6 +1818,7 @@ class myformat implements Serializable
} }
} }
@SuppressWarnings("serial")
class MyNumberFormatTest extends NumberFormat { class MyNumberFormatTest extends NumberFormat {
public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) { public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
return new StringBuffer(""); return new StringBuffer("");
@ -1825,6 +1827,6 @@ class MyNumberFormatTest extends NumberFormat {
return new StringBuffer(""); return new StringBuffer("");
} }
public Number parse(String text, ParsePosition parsePosition) { public Number parse(String text, ParsePosition parsePosition) {
return new Integer(0); return 0;
} }
} }

View File

@ -130,11 +130,11 @@ public class NumberRoundTrip extends IntlTest {
} }
public void doTest(NumberFormat fmt, double value) { public void doTest(NumberFormat fmt, double value) {
doTest(fmt, new Double(value)); doTest(fmt, Double.valueOf(value));
} }
public void doTest(NumberFormat fmt, long value) { public void doTest(NumberFormat fmt, long value) {
doTest(fmt, new Long(value)); doTest(fmt, Long.valueOf(value));
} }
static double proportionalError(Number a, Number b) { static double proportionalError(Number a, Number b) {

View File

@ -403,7 +403,7 @@ public class NumberTest extends IntlTest
float[] parseExpected = { 0, 0, 12345, -12345 }; float[] parseExpected = { 0, 0, 12345, -12345 };
for (int i = 0; i < parseInput.length; i++) { for (int i = 0; i < parseInput.length; i++) {
float result = ((Number) format.parse(parseInput[i])).floatValue(); float result = format.parse(parseInput[i]).floatValue();
if (result != parseExpected[i]) { if (result != parseExpected[i]) {
errln("FAIL: Expected " + parseExpected[i] + ", got " + result); errln("FAIL: Expected " + parseExpected[i] + ", got " + result);
} }

View File

@ -62,6 +62,7 @@ public class SerializationLoadTest {
} }
} }
@SuppressWarnings("serial")
class CheckDecimalFormat implements Serializable class CheckDecimalFormat implements Serializable
{ {
DecimalFormat _decFormat = (DecimalFormat)NumberFormat.getInstance(); DecimalFormat _decFormat = (DecimalFormat)NumberFormat.getInstance();
@ -73,6 +74,7 @@ class CheckDecimalFormat implements Serializable
} }
} }
@SuppressWarnings("serial")
class CheckDecimalFormatSymbols implements Serializable class CheckDecimalFormatSymbols implements Serializable
{ {
DecimalFormatSymbols _decFormatSymbols = new DecimalFormatSymbols(); DecimalFormatSymbols _decFormatSymbols = new DecimalFormatSymbols();

View File

@ -57,6 +57,7 @@ public class SerializationSaveTest {
} }
} }
@SuppressWarnings("serial")
class CheckDecimalFormat implements Serializable class CheckDecimalFormat implements Serializable
{ {
DecimalFormat _decFormat = (DecimalFormat)NumberFormat.getInstance(); DecimalFormat _decFormat = (DecimalFormat)NumberFormat.getInstance();
@ -68,6 +69,7 @@ class CheckDecimalFormat implements Serializable
} }
} }
@SuppressWarnings("serial")
class CheckDecimalFormatSymbols implements Serializable class CheckDecimalFormatSymbols implements Serializable
{ {
DecimalFormatSymbols _decFormatSymbols = new DecimalFormatSymbols(); DecimalFormatSymbols _decFormatSymbols = new DecimalFormatSymbols();

View File

@ -37,6 +37,7 @@ import java.text.*;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.text.AttributedCharacterIterator.Attribute;
/** /**
* FormatTester creates Formats, and tests the resulting FieldPositions * FormatTester creates Formats, and tests the resulting FieldPositions
@ -94,7 +95,6 @@ import java.util.concurrent.atomic.AtomicLong;
* Any lines starting with {@code '#'} are comment lines and ignored. * Any lines starting with {@code '#'} are comment lines and ignored.
*/ */
public class FormatIteratorTest extends IntlTest { public class FormatIteratorTest extends IntlTest {
private static HashMap attrs;
private Format format; private Format format;
private Object value; private Object value;
private String text; private String text;
@ -143,30 +143,31 @@ public class FormatIteratorTest extends IntlTest {
"dateFormat.props")); "dateFormat.props"));
} }
@SuppressWarnings("unchecked")
private void _test(File file) { private void _test(File file) {
try { try {
attrs = new HashMap();
logln("testing: " + file); logln("testing: " + file);
PParser parser = new PParser(); PParser parser = new PParser();
Hashtable contents = parser.parse(new BufferedReader( Map<String,Object> contents = parser.parse(new BufferedReader(
new FileReader(file))); new FileReader(file)));
Vector test = (Vector)contents.get("tests"); List<Object> test = (List)contents.get("tests");
for (int counter = 0; counter < test.size(); counter++) { for (int counter = 0; counter < test.size(); counter++) {
logln("creating: " + (counter / 2)); logln("creating: " + (counter / 2));
AttributedCharacterIterator iterator = AttributedCharacterIterator iterator =
create((Hashtable)test.get(counter)); create((Map)test.get(counter));
logln("verifying: " + (counter / 2)); logln("verifying: " + (counter / 2));
verify(iterator, (Hashtable)test.get(++counter)); verify(iterator, (Map)test.get(++counter));
} }
} catch (IOException ioe) { } catch (IOException ioe) {
errln("Error reading: " + ioe); errln("Error reading: " + ioe);
} }
} }
public void verify(AttributedCharacterIterator iterator,Hashtable table) { @SuppressWarnings("unchecked")
public void verify(AttributedCharacterIterator iterator,Map<String,Object> table) {
int length = Integer.parseInt((String)table.get("length")); int length = Integer.parseInt((String)table.get("length"));
// Verify the text // Verify the text
@ -185,10 +186,10 @@ public class FormatIteratorTest extends IntlTest {
for (int counter = 0; counter < length; counter++) { for (int counter = 0; counter < length; counter++) {
iterator.setIndex(counter); iterator.setIndex(counter);
if (!verifyAttributes(iterator.getAttributes().keySet(), if (!verifyAttributes(iterator.getAttributes().keySet(),
makeAttributes((Vector)table.get(Integer. makeAttributes((List)table.get(Integer.
toString(counter))))) { toString(counter))))) {
errln("Attributes don't match at " + counter + " expecting " + errln("Attributes don't match at " + counter + " expecting " +
makeAttributes((Vector)table.get(Integer.toString makeAttributes((List)table.get(Integer.toString
(counter))) + " got " + (counter))) + " got " +
iterator.getAttributes().keySet()); iterator.getAttributes().keySet());
} }
@ -196,10 +197,10 @@ public class FormatIteratorTest extends IntlTest {
for (int counter = length - 1; counter >= 0; counter--) { for (int counter = length - 1; counter >= 0; counter--) {
iterator.setIndex(counter); iterator.setIndex(counter);
if (!verifyAttributes(iterator.getAttributes().keySet(), if (!verifyAttributes(iterator.getAttributes().keySet(),
makeAttributes((Vector)table.get(Integer. makeAttributes((List)table.get(Integer.
toString(counter))))) { toString(counter))))) {
errln("Attributes don't match at " + counter + " expecting " + errln("Attributes don't match at " + counter + " expecting " +
makeAttributes((Vector)table.get(Integer.toString makeAttributes((List)table.get(Integer.toString
(counter))) + " got " + (counter))) + " got " +
iterator.getAttributes().keySet()); iterator.getAttributes().keySet());
} }
@ -207,31 +208,33 @@ public class FormatIteratorTest extends IntlTest {
verifyLimits(iterator, table); verifyLimits(iterator, table);
text = escapeIfNecessary((String)table.get("text")); text = escapeIfNecessary((String)table.get("text"));
Vector fps = (Vector)table.get("fieldPositions"); List<Object> fps = (List)table.get("fieldPositions");
if (fps != null) { if (fps != null) {
for (int counter = 0; counter < fps.size(); counter++) { for (int counter = 0; counter < fps.size(); counter++) {
verifyFieldPosition(counter, (Hashtable)fps.get(counter)); verifyFieldPosition(counter,(Map)fps.get(counter));
} }
} }
} }
@SuppressWarnings("unchecked")
private void verifyLimits(AttributedCharacterIterator iterator, private void verifyLimits(AttributedCharacterIterator iterator,
Hashtable table) { Map<String,Object> table) {
Vector limits = (Vector)table.get("limits"); List<Object> limits = (List)table.get("limits");
if (limits != null) { if (limits != null) {
for (int counter = 0; counter < limits.size(); counter++) { for (int counter = 0; counter < limits.size(); counter++) {
verifyLimit(iterator, (Hashtable)limits.get(counter)); verifyLimit(iterator, (Map)limits.get(counter));
} }
} }
} }
private void verifyLimit(AttributedCharacterIterator iterator, private void verifyLimit(AttributedCharacterIterator iterator,
Hashtable table) { Map<String,Object> table) {
int begin = Integer.parseInt((String)table.get("begin")); int begin = Integer.parseInt((String)table.get("begin"));
int end = Integer.parseInt((String)table.get("end")); int end = Integer.parseInt((String)table.get("end"));
Set attrs = makeAttributes((Vector)table.get("attributes")); @SuppressWarnings("unchecked")
Set<Attribute> attrs = makeAttributes((List)table.get("attributes"));
String begin2S = (String)table.get("begin2"); String begin2S = (String)table.get("begin2");
int begin2 = (begin2S != null) ? Integer.parseInt(begin2S) : begin; int begin2 = (begin2S != null) ? Integer.parseInt(begin2S) : begin;
String end2S = (String)table.get("end2"); String end2S = (String)table.get("end2");
@ -262,9 +265,9 @@ public class FormatIteratorTest extends IntlTest {
} }
} }
private boolean verifyAttributes(Set a, Set b) { private boolean verifyAttributes(Set<Attribute> a, Set<Attribute> b) {
boolean aEmpty = (a.size() == 0); boolean aEmpty = a.isEmpty();
boolean bEmpty = (b.size() == 0); boolean bEmpty = b.isEmpty();
if (aEmpty && bEmpty) { if (aEmpty && bEmpty) {
return true; return true;
@ -284,14 +287,14 @@ public class FormatIteratorTest extends IntlTest {
return buffer.toString(); return buffer.toString();
} }
private void verifyFieldPosition(int index, Hashtable table) { private void verifyFieldPosition(int index, Map<String,Object> table) {
Object o = table.get("field"); Object o = table.get("field");
int begin = Integer.parseInt((String)table.get("begin")); int begin = Integer.parseInt((String)table.get("begin"));
int end = Integer.parseInt((String)table.get("end")); int end = Integer.parseInt((String)table.get("end"));
if (o != null) { if (o != null) {
FieldPosition fp = new FieldPosition(((Integer) FieldPosition fp = new FieldPosition(((Integer)
lookupField((String)o)).intValue()); lookupField((String)o)));
verifyFieldPosition(fp, begin, end, index); verifyFieldPosition(fp, begin, end, index);
} }
@ -322,11 +325,11 @@ public class FormatIteratorTest extends IntlTest {
} }
} }
public AttributedCharacterIterator create(Hashtable table) { public AttributedCharacterIterator create(Map<String,Object> table) {
format = (Format)createInstance((String)table.get("class"), format = (Format)createInstance((String)table.get("class"),
((Vector)table.get("args")).toArray()); ((List)table.get("args")).toArray());
value = createInstance((String)table.get("valueClass"), value = createInstance((String)table.get("valueClass"),
((Vector)table.get("valueArgs")).toArray()); ((List)table.get("valueArgs")).toArray());
logln("Created format: " + format + " value " + value); logln("Created format: " + format + " value " + value);
AttributedCharacterIterator aci = format. AttributedCharacterIterator aci = format.
@ -343,11 +346,12 @@ public class FormatIteratorTest extends IntlTest {
private Object createInstance(String className, Object[] args) { private Object createInstance(String className, Object[] args) {
if (className.equals("java.lang.reflect.Array")) { if (className.equals("java.lang.reflect.Array")) {
for (int counter = 0; counter < args.length; counter++) { for (int counter = 0; counter < args.length; counter++) {
if (args[counter] instanceof Vector) { if (args[counter] instanceof List) {
Vector v = (Vector)args[counter]; @SuppressWarnings("unchecked")
List<Object> v = (List<Object>)args[counter];
args[counter] = createInstance((String)v.get(0), args[counter] = createInstance((String)v.get(0),
((Vector)v.get(1)).toArray()); ((List)v.get(1)).toArray());
} }
} }
return args; return args;
@ -361,9 +365,9 @@ public class FormatIteratorTest extends IntlTest {
} else if (className.equals("java.util.concurrent.atomic.AtomicLong")) { } else if (className.equals("java.util.concurrent.atomic.AtomicLong")) {
return new AtomicLong(Long.valueOf((String)args[0])); return new AtomicLong(Long.valueOf((String)args[0]));
} else { } else {
Class klass = lookupClass(className); Class<?> klass = lookupClass(className);
Constructor cons = klass.getConstructor( Constructor<?> cons = klass.getConstructor(
new Class[] { String.class }); new Class<?>[] { String.class });
Object value = cons.newInstance(args); Object value = cons.newInstance(args);
return value; return value;
@ -374,20 +378,20 @@ public class FormatIteratorTest extends IntlTest {
} }
} }
private Class lookupClass(String name) throws ClassNotFoundException { private Class<?> lookupClass(String name) throws ClassNotFoundException {
try { try {
Class klass = Class.forName(name); Class<?> klass = Class.forName(name);
return klass; return klass;
} catch (ClassNotFoundException e1) {} } catch (ClassNotFoundException e1) {}
try { try {
Class klass = Class.forName("java.lang." + name); Class<?> klass = Class.forName("java.lang." + name);
return klass; return klass;
} catch (ClassNotFoundException e1) {} } catch (ClassNotFoundException e1) {}
Class klass = Class.forName("java.text." + name); Class<?> klass = Class.forName("java.text." + name);
return klass; return klass;
} }
@ -397,7 +401,7 @@ public class FormatIteratorTest extends IntlTest {
try { try {
int dotIndex = name.indexOf('.'); int dotIndex = name.indexOf('.');
Class klass = lookupClass(name.substring(0, dotIndex)); Class<?> klass = lookupClass(name.substring(0, dotIndex));
String fieldName = name.substring(dotIndex + 1); String fieldName = name.substring(dotIndex + 1);
Field[] fields = klass.getFields(); Field[] fields = klass.getFields();
@ -429,8 +433,8 @@ public class FormatIteratorTest extends IntlTest {
return string; return string;
} }
public Set makeAttributes(Vector names) { public Set<Attribute> makeAttributes(List<Object> names) {
HashSet set = new HashSet(Math.max(1, names.size())); Set<Attribute> set = new HashSet<>(Math.max(1, names.size()));
for (int counter = 0; counter < names.size(); counter++) { for (int counter = 0; counter < names.size(); counter++) {
set.add(makeAttribute((String)names.get(counter))); set.add(makeAttribute((String)names.get(counter)));

View File

@ -58,7 +58,7 @@ public class PParser {
public PParser() { public PParser() {
} }
public Hashtable parse(Reader r) throws IOException { public Map<String,Object> parse(Reader r) throws IOException {
this.reader = r; this.reader = r;
bufferedToken = false; bufferedToken = false;
lineNumber = 0; lineNumber = 0;
@ -91,23 +91,23 @@ public class PParser {
} }
protected Object parseArray() throws IOException { protected Object parseArray() throws IOException {
Vector array = new Vector(); List<Object> array = new ArrayList<>();
int token; int token;
while ((token = getToken()) != CLOSE_ARRAY) { while ((token = getToken()) != CLOSE_ARRAY) {
if (token == MORE) { if (token == MORE) {
token = getToken(); token = getToken();
} }
if (token != CLOSE_ARRAY) { if (token != CLOSE_ARRAY) {
array.addElement(parseValue(token)); array.add(parseValue(token));
} }
} }
return array; return array;
} }
protected Hashtable parsePair() throws IOException { protected Map<String,Object> parsePair() throws IOException {
Hashtable ht = new Hashtable(11); Map<String,Object> ht = new HashMap<>(11);
int token; int token;
while ((token = getToken()) != CLOSE_PAIR) { while ((token = getToken()) != CLOSE_PAIR) {
if (token != STRING) { if (token != STRING) {
@ -133,11 +133,12 @@ public class PParser {
} }
protected int getToken() throws IOException { protected int getToken() throws IOException {
int token = getToken(false, false); int token = getToken(false, false);
return token; return token;
} }
@SuppressWarnings("fallthrough")
protected int getToken(boolean wantsWS, boolean inString) protected int getToken(boolean wantsWS, boolean inString)
throws IOException { throws IOException {
if (bufferedToken) { if (bufferedToken) {
@ -225,31 +226,26 @@ public class PParser {
throw new RuntimeException(errorString + " at line " + lineNumber + " column " + column); throw new RuntimeException(errorString + " at line " + lineNumber + " column " + column);
} }
@SuppressWarnings("unchecked")
public static void dump(Object o) { public static void dump(Object o) {
if (o instanceof String) { if (o instanceof String) {
System.out.print(o); System.out.print(o);
} else if(o instanceof Vector) { } else if(o instanceof List) {
Enumeration e = ((Vector)o).elements();
dump(" ("); dump(" (");
while (e.hasMoreElements()) { ((List)o).forEach((l) -> {
dump(e.nextElement()); dump(l);
dump(" -- "); dump(" -- ");
} });
dump(" )"); dump(" )");
} else { } else {
Hashtable ht = (Hashtable)o; Map<String,Object> ht = (Map<String,Object>)o;
Enumeration e = ht.keys();
dump(" {"); dump(" {");
while (e.hasMoreElements()) { ht.keySet().forEach(l -> {
Object key = e.nextElement(); dump(l);
dump(key);
dump(" = "); dump(" = ");
dump(ht.get(key)); dump(ht.get(l));
dump(";"); dump(";");
} });
dump(" }"); dump(" }");
} }
} }
@ -259,9 +255,9 @@ public class PParser {
System.out.println("need filename"); System.out.println("need filename");
} else { } else {
try { try {
FileReader fr = new FileReader(args[0]); FileReader fr = new FileReader(args[0]);
PParser parser = new PParser(); PParser parser = new PParser();
Hashtable ht = parser.parse(fr); Map<String,Object> ht = parser.parse(fr);
dump(ht); dump(ht);
System.out.println(); System.out.println();