author | okutsu |
Fri, 27 May 2016 14:33:48 +0900 | |
changeset 38581 | e761c1ccd13e |
child 40455 | db40a6f6f274 |
permissions | -rw-r--r-- |
38581
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1 |
/* |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
2 |
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
4 |
* |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
8 |
* |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
13 |
* accompanied this code). |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
14 |
* |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
18 |
* |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
21 |
* questions. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
22 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
23 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
24 |
import java.text.*; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
25 |
import java.util.*; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
26 |
import java.io.*; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
27 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
28 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
29 |
* @test |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
30 |
* @bug 4029195 4052408 4056591 4059917 4060212 4061287 4065240 4071441 4073003 |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
31 |
* 4089106 4100302 4101483 4103340 4103341 4104136 4104522 4106807 4108407 |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
32 |
* 4134203 4138203 4148168 4151631 4151706 4153860 4162071 4182066 4209272 4210209 |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
33 |
* 4213086 4250359 4253490 4266432 4406615 4413980 8008577 |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
34 |
* @library /java/text/testlib |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
35 |
* @run main/othervm -Djava.locale.providers=COMPAT,SPI DateFormatRegression |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
36 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
37 |
public class DateFormatRegression extends IntlTest { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
38 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
39 |
public static void main(String[] args) throws Exception { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
40 |
new DateFormatRegression().run(args); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
41 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
42 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
43 |
public void Test4029195() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
44 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
45 |
Date today = new Date(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
46 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
47 |
logln("today: " + today); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
48 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
49 |
SimpleDateFormat sdf = (SimpleDateFormat)SimpleDateFormat.getDateInstance(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
50 |
logln("pattern: " + sdf.toPattern()); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
51 |
logln("today: " + sdf.format(today)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
52 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
53 |
sdf.applyPattern("G yyyy DDD"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
54 |
String todayS = sdf.format(today); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
55 |
logln("today: " + todayS); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
56 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
57 |
today = sdf.parse(todayS); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
58 |
logln("today date: " + today); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
59 |
} catch(Exception e) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
60 |
logln("Error reparsing date: " + e.getMessage()); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
61 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
62 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
63 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
64 |
String rt = sdf.format(sdf.parse(todayS)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
65 |
logln("round trip: " + rt); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
66 |
if (!rt.equals(todayS)) errln("Fail: Want " + todayS + " Got " + rt); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
67 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
68 |
catch (ParseException e) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
69 |
errln("Fail: " + e); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
70 |
e.printStackTrace(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
71 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
72 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
73 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
74 |
public void Test4052408() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
75 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
76 |
DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
77 |
DateFormat.SHORT, Locale.US); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
78 |
Date date = new Date(97, Calendar.MAY, 3, 8, 55); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
79 |
String str; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
80 |
logln(str = fmt.format(date)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
81 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
82 |
if (!str.equals("5/3/97 8:55 AM")) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
83 |
errln("Fail: Test broken; Want 5/3/97 8:55 AM Got " + str); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
84 |
Hashtable expected = new Hashtable(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
85 |
expected.put(new Integer(DateFormat.MONTH_FIELD), "5"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
86 |
expected.put(new Integer(DateFormat.DATE_FIELD), "3"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
87 |
expected.put(new Integer(DateFormat.YEAR_FIELD), "97"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
88 |
expected.put(new Integer(DateFormat.HOUR1_FIELD), "8"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
89 |
expected.put(new Integer(DateFormat.MINUTE_FIELD), "55"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
90 |
expected.put(new Integer(DateFormat.AM_PM_FIELD), "AM"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
91 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
92 |
StringBuffer buf = new StringBuffer(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
93 |
String fieldNames[] = { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
94 |
"ERA_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
95 |
"YEAR_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
96 |
"MONTH_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
97 |
"DATE_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
98 |
"HOUR_OF_DAY1_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
99 |
"HOUR_OF_DAY0_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
100 |
"MINUTE_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
101 |
"SECOND_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
102 |
"MILLISECOND_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
103 |
"DAY_OF_WEEK_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
104 |
"DAY_OF_YEAR_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
105 |
"DAY_OF_WEEK_IN_MONTH_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
106 |
"WEEK_OF_YEAR_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
107 |
"WEEK_OF_MONTH_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
108 |
"AM_PM_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
109 |
"HOUR1_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
110 |
"HOUR0_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
111 |
"TIMEZONE_FIELD", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
112 |
}; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
113 |
boolean pass = true; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
114 |
for (int i=0; i<=17; ++i) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
115 |
FieldPosition pos = new FieldPosition(i); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
116 |
fmt.format(date, buf, pos); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
117 |
char[] dst = new char[pos.getEndIndex() - pos.getBeginIndex()]; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
118 |
buf.getChars(pos.getBeginIndex(), pos.getEndIndex(), dst, 0); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
119 |
str = new String(dst); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
120 |
log(i + ": " + fieldNames[i] + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
121 |
", \"" + str + "\", " + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
122 |
pos.getBeginIndex() + ", " + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
123 |
pos.getEndIndex()); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
124 |
String exp = (String) expected.get(new Integer(i)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
125 |
if ((exp == null && str.length() == 0) || |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
126 |
str.equals(exp)) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
127 |
logln(" ok"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
128 |
else { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
129 |
logln(" expected " + exp); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
130 |
pass = false; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
131 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
132 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
133 |
if (!pass) errln("Fail: FieldPosition not set right by DateFormat"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
134 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
135 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
136 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
137 |
* Verify the function of the [s|g]et2DigitYearStart() API. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
138 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
139 |
public void Test4056591() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
140 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
141 |
SimpleDateFormat fmt = new SimpleDateFormat("yyMMdd", Locale.US); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
142 |
Date start = new Date(1809-1900, Calendar.DECEMBER, 25); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
143 |
fmt.set2DigitYearStart(start); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
144 |
if (!fmt.get2DigitYearStart().equals(start)) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
145 |
errln("get2DigitYearStart broken"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
146 |
Object[] DATA = { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
147 |
"091225", new Date(1809-1900, Calendar.DECEMBER, 25), |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
148 |
"091224", new Date(1909-1900, Calendar.DECEMBER, 24), |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
149 |
"091226", new Date(1809-1900, Calendar.DECEMBER, 26), |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
150 |
"611225", new Date(1861-1900, Calendar.DECEMBER, 25), |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
151 |
}; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
152 |
for (int i=0; i<DATA.length; i+=2) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
153 |
String s = (String) DATA[i]; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
154 |
Date exp = (Date) DATA[i+1]; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
155 |
Date got = fmt.parse(s); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
156 |
logln(s + " -> " + got + "; exp " + exp); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
157 |
if (!got.equals(exp)) errln("set2DigitYearStart broken"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
158 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
159 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
160 |
catch (ParseException e) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
161 |
errln("Fail: " + e); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
162 |
e.printStackTrace(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
163 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
164 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
165 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
166 |
public void Test4059917() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
167 |
if (Locale.getDefault().equals(new Locale("hi", "IN"))) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
168 |
return; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
169 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
170 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
171 |
SimpleDateFormat fmt; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
172 |
String myDate; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
173 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
174 |
fmt = new SimpleDateFormat( "yyyy/MM/dd" ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
175 |
myDate = "1997/01/01"; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
176 |
aux917( fmt, myDate ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
177 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
178 |
fmt = new SimpleDateFormat( "yyyyMMdd" ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
179 |
myDate = "19970101"; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
180 |
aux917( fmt, myDate ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
181 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
182 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
183 |
void aux917( SimpleDateFormat fmt, String str ) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
184 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
185 |
logln( "==================" ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
186 |
logln( "testIt: pattern=" + fmt.toPattern() + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
187 |
" string=" + str ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
188 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
189 |
Object o; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
190 |
o = fmt.parseObject( str ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
191 |
logln( "Parsed object: " + o ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
192 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
193 |
String formatted = fmt.format( o ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
194 |
logln( "Formatted string: " + formatted ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
195 |
if (!formatted.equals(str)) errln("Fail: Want " + str + " Got " + formatted); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
196 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
197 |
catch (ParseException e) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
198 |
errln("Fail: " + e); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
199 |
e.printStackTrace(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
200 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
201 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
202 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
203 |
public void Test4060212() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
204 |
Locale savedLocale = Locale.getDefault(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
205 |
Locale.setDefault(Locale.US); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
206 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
207 |
String dateString = "1995-040.05:01:29"; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
208 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
209 |
logln( "dateString= " + dateString ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
210 |
logln("Using yyyy-DDD.hh:mm:ss"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
211 |
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-DDD.hh:mm:ss"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
212 |
ParsePosition pos = new ParsePosition(0); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
213 |
Date myDate = formatter.parse( dateString, pos ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
214 |
String myString = DateFormat.getDateTimeInstance( DateFormat.FULL, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
215 |
DateFormat.LONG).format( myDate ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
216 |
logln( myString ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
217 |
Calendar cal = new GregorianCalendar(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
218 |
cal.setTime(myDate); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
219 |
if (cal.get(Calendar.DAY_OF_YEAR) != 40) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
220 |
errln("Fail: Got " + cal.get(Calendar.DAY_OF_YEAR) + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
221 |
" Want 40"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
222 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
223 |
logln("Using yyyy-ddd.hh:mm:ss"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
224 |
formatter = new SimpleDateFormat("yyyy-ddd.hh:mm:ss"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
225 |
pos = new ParsePosition(0); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
226 |
myDate = formatter.parse( dateString, pos ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
227 |
myString = DateFormat.getDateTimeInstance( DateFormat.FULL, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
228 |
DateFormat.LONG).format( myDate ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
229 |
logln( myString ); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
230 |
cal.setTime(myDate); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
231 |
if (cal.get(Calendar.DAY_OF_YEAR) != 40) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
232 |
errln("Fail: Got " + cal.get(Calendar.DAY_OF_YEAR) + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
233 |
" Want 40"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
234 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
235 |
finally { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
236 |
Locale.setDefault(savedLocale); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
237 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
238 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
239 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
240 |
public void Test4061287() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
241 |
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
242 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
243 |
logln(df.parse("35/01/1971").toString()); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
244 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
245 |
catch (ParseException e) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
246 |
errln("Fail: " + e); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
247 |
e.printStackTrace(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
248 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
249 |
df.setLenient(false); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
250 |
boolean ok = false; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
251 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
252 |
logln(df.parse("35/01/1971").toString()); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
253 |
} catch (ParseException e) {ok=true;} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
254 |
if (!ok) errln("Fail: Lenient not working"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
255 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
256 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
257 |
public void Test4065240() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
258 |
Date curDate; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
259 |
DateFormat shortdate, fulldate; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
260 |
String strShortDate, strFullDate; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
261 |
Locale saveLocale = Locale.getDefault(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
262 |
TimeZone saveZone = TimeZone.getDefault(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
263 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
264 |
Locale curLocale = new Locale("de","DE"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
265 |
Locale.setDefault(curLocale); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
266 |
TimeZone.setDefault(TimeZone.getTimeZone("EST")); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
267 |
curDate = new Date(98, 0, 1); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
268 |
shortdate = DateFormat.getDateInstance(DateFormat.SHORT); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
269 |
fulldate = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
270 |
); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
271 |
strShortDate = new String("The current date (short form) is " + shortdate. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
272 |
format(curDate)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
273 |
strFullDate = new String("The current date (long form) is " + fulldate.format(curDate)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
274 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
275 |
logln(strShortDate); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
276 |
logln(strFullDate); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
277 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
278 |
// UPDATE THIS AS ZONE NAME RESOURCE FOR <EST> in de_DE is updated |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
279 |
if (!strFullDate.endsWith("EST") |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
280 |
&& !strFullDate.endsWith("GMT-05:00")) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
281 |
errln("Fail: Want GMT-05:00"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
282 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
283 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
284 |
finally { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
285 |
Locale.setDefault(saveLocale); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
286 |
TimeZone.setDefault(saveZone); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
287 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
288 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
289 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
290 |
/* |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
291 |
DateFormat.equals is too narrowly defined. As a result, MessageFormat |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
292 |
does not work correctly. DateFormat.equals needs to be written so |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
293 |
that the Calendar sub-object is not compared using Calendar.equals, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
294 |
but rather compared for equivalency. This may necessitate adding a |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
295 |
(package private) method to Calendar to test for equivalency. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
296 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
297 |
Currently this bug breaks MessageFormat.toPattern |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
298 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
299 |
public void Test4071441() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
300 |
DateFormat fmtA = DateFormat.getInstance(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
301 |
DateFormat fmtB = DateFormat.getInstance(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
302 |
Calendar calA = fmtA.getCalendar(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
303 |
Calendar calB = fmtB.getCalendar(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
304 |
Date epoch = new Date(0); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
305 |
Date xmas = new Date(61, Calendar.DECEMBER, 25); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
306 |
calA.setTime(epoch); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
307 |
calB.setTime(epoch); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
308 |
if (!calA.equals(calB)) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
309 |
errln("Fail: Can't complete test; Calendar instances unequal"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
310 |
if (!fmtA.equals(fmtB)) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
311 |
errln("Fail: DateFormat unequal when Calendars equal"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
312 |
calB.setTime(xmas); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
313 |
if (calA.equals(calB)) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
314 |
errln("Fail: Can't complete test; Calendar instances equal"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
315 |
if (!fmtA.equals(fmtB)) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
316 |
errln("Fail: DateFormat unequal when Calendars equivalent"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
317 |
logln("DateFormat.equals ok"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
318 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
319 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
320 |
/* The java.text.DateFormat.parse(String) method expects for the |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
321 |
US locale a string formatted according to mm/dd/yy and parses it |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
322 |
correctly. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
323 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
324 |
When given a string mm/dd/yyyy it only parses up to the first |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
325 |
two y's, typically resulting in a date in the year 1919. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
326 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
327 |
Please extend the parsing method(s) to handle strings with |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
328 |
four-digit year values (probably also applicable to various |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
329 |
other locales. */ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
330 |
public void Test4073003() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
331 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
332 |
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
333 |
String[] tests = { "12/25/61", "12/25/1961", "4/3/2010", "4/3/10" }; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
334 |
for (int i=0; i<tests.length; i+=2) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
335 |
Date d = fmt.parse(tests[i]); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
336 |
Date dd = fmt.parse(tests[i+1]); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
337 |
String s = fmt.format(d); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
338 |
String ss = fmt.format(dd); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
339 |
if (!d.equals(dd)) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
340 |
errln("Fail: " + d + " != " + dd); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
341 |
if (!s.equals(ss)) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
342 |
errln("Fail: " + s + " != " + ss); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
343 |
logln("Ok: " + s + " " + d); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
344 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
345 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
346 |
catch (ParseException e) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
347 |
errln("Fail: " + e); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
348 |
e.printStackTrace(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
349 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
350 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
351 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
352 |
public void Test4089106() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
353 |
TimeZone def = TimeZone.getDefault(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
354 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
355 |
TimeZone z = new SimpleTimeZone((int)(1.25 * 3600000), "FAKEZONE"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
356 |
TimeZone.setDefault(z); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
357 |
SimpleDateFormat f = new SimpleDateFormat(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
358 |
if (!f.getTimeZone().equals(z)) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
359 |
errln("Fail: SimpleTimeZone should use TimeZone.getDefault()"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
360 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
361 |
finally { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
362 |
TimeZone.setDefault(def); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
363 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
364 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
365 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
366 |
public void Test4100302() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
367 |
Locale[] locales = new Locale[] { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
368 |
Locale.CANADA, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
369 |
Locale.CANADA_FRENCH, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
370 |
Locale.CHINA, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
371 |
Locale.CHINESE, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
372 |
Locale.ENGLISH, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
373 |
Locale.FRANCE, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
374 |
Locale.FRENCH, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
375 |
Locale.GERMAN, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
376 |
Locale.GERMANY, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
377 |
Locale.ITALIAN, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
378 |
Locale.ITALY, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
379 |
Locale.JAPAN, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
380 |
Locale.JAPANESE, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
381 |
Locale.KOREA, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
382 |
Locale.KOREAN, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
383 |
Locale.PRC, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
384 |
Locale.SIMPLIFIED_CHINESE, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
385 |
Locale.TAIWAN, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
386 |
Locale.TRADITIONAL_CHINESE, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
387 |
Locale.UK, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
388 |
Locale.US |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
389 |
}; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
390 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
391 |
boolean pass = true; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
392 |
for(int i = 0; i < locales.length; i++) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
393 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
394 |
Format format = DateFormat.getDateTimeInstance(DateFormat.FULL, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
395 |
DateFormat.FULL, locales[i]); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
396 |
byte[] bytes; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
397 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
398 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
399 |
ObjectOutputStream oos = new ObjectOutputStream(baos); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
400 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
401 |
oos.writeObject(format); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
402 |
oos.flush(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
403 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
404 |
baos.close(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
405 |
bytes = baos.toByteArray(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
406 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
407 |
ObjectInputStream ois = |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
408 |
new ObjectInputStream(new ByteArrayInputStream(bytes)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
409 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
410 |
if (!format.equals(ois.readObject())) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
411 |
pass = false; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
412 |
logln("DateFormat instance for locale " + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
413 |
locales[i] + " is incorrectly serialized/deserialized."); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
414 |
} else { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
415 |
logln("DateFormat instance for locale " + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
416 |
locales[i] + " is OKAY."); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
417 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
418 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
419 |
if (!pass) errln("Fail: DateFormat serialization/equality bug"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
420 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
421 |
catch (IOException e) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
422 |
errln("Fail: " + e); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
423 |
e.printStackTrace(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
424 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
425 |
catch (ClassNotFoundException e) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
426 |
errln("Fail: " + e); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
427 |
e.printStackTrace(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
428 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
429 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
430 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
431 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
432 |
* Test whether DataFormat can be serialized/deserialized correctly |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
433 |
* even if invalid/customized TimeZone is used. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
434 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
435 |
public void Test4413980() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
436 |
TimeZone savedTimeZone = TimeZone.getDefault(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
437 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
438 |
boolean pass = true; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
439 |
String[] IDs = new String[] {"Undefined", "PST", "US/Pacific", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
440 |
"GMT+3:00", "GMT-01:30"}; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
441 |
for (int i = 0; i < IDs.length; i++) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
442 |
TimeZone tz = TimeZone.getTimeZone(IDs[i]); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
443 |
TimeZone.setDefault(tz); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
444 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
445 |
Format format = DateFormat.getDateTimeInstance(DateFormat.FULL, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
446 |
DateFormat.FULL); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
447 |
byte[] bytes; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
448 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
449 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
450 |
ObjectOutputStream oos = new ObjectOutputStream(baos); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
451 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
452 |
oos.writeObject(format); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
453 |
oos.flush(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
454 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
455 |
baos.close(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
456 |
bytes = baos.toByteArray(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
457 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
458 |
ObjectInputStream ois = |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
459 |
new ObjectInputStream(new ByteArrayInputStream(bytes)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
460 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
461 |
if (!format.equals(ois.readObject())) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
462 |
pass = false; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
463 |
logln("DateFormat instance which uses TimeZone <" + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
464 |
IDs[i] + "> is incorrectly serialized/deserialized."); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
465 |
} else { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
466 |
logln("DateFormat instance which uses TimeZone <" + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
467 |
IDs[i] + "> is correctly serialized/deserialized."); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
468 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
469 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
470 |
if (!pass) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
471 |
errln("Fail: DateFormat serialization/equality bug"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
472 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
473 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
474 |
catch (IOException e) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
475 |
errln("Fail: " + e); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
476 |
e.printStackTrace(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
477 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
478 |
catch (ClassNotFoundException e) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
479 |
errln("Fail: " + e); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
480 |
e.printStackTrace(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
481 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
482 |
finally { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
483 |
TimeZone.setDefault(savedTimeZone); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
484 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
485 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
486 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
487 |
public void Test4101483() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
488 |
SimpleDateFormat sdf = new SimpleDateFormat("z", Locale.US); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
489 |
FieldPosition fp = new FieldPosition(DateFormat.TIMEZONE_FIELD); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
490 |
Date d= new Date(9234567890L); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
491 |
StringBuffer buf = new StringBuffer(""); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
492 |
logln(sdf.format(d, buf, fp).toString()); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
493 |
logln(d + " => " + buf); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
494 |
logln("beginIndex = " + fp.getBeginIndex()); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
495 |
logln("endIndex = " + fp.getEndIndex()); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
496 |
if (fp.getBeginIndex() == fp.getEndIndex()) errln("Fail: Empty field"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
497 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
498 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
499 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
500 |
* Bug 4103340 |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
501 |
* Bug 4138203 |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
502 |
* This bug really only works in Locale.US, since that's what the locale |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
503 |
* used for Date.toString() is. Bug 4138203 reports that it fails on Korean |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
504 |
* NT; it would actually have failed on any non-US locale. Now it should |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
505 |
* work on all locales. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
506 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
507 |
public void Test4103340() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
508 |
// choose a date that is the FIRST of some month |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
509 |
// and some arbitrary time |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
510 |
Date d=new Date(97, 3, 1, 1, 1, 1); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
511 |
SimpleDateFormat df=new SimpleDateFormat("MMMM", Locale.US); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
512 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
513 |
String s = d.toString(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
514 |
String s2 = df.format(d); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
515 |
logln("Date="+s); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
516 |
logln("DF="+s2); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
517 |
if (s.indexOf(s2.substring(0,2)) == -1) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
518 |
errln("Months should match"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
519 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
520 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
521 |
public void Test4103341() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
522 |
TimeZone saveZone =TimeZone.getDefault(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
523 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
524 |
TimeZone.setDefault(TimeZone.getTimeZone("CST")); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
525 |
SimpleDateFormat simple = new SimpleDateFormat("MM/dd/yyyy HH:mm"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
526 |
if (!simple.getTimeZone().equals(TimeZone.getDefault())) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
527 |
errln("Fail: SimpleDateFormat not using default zone"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
528 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
529 |
finally { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
530 |
TimeZone.setDefault(saveZone); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
531 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
532 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
533 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
534 |
public void Test4104136() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
535 |
SimpleDateFormat sdf = new SimpleDateFormat(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
536 |
String pattern = "'time' hh:mm"; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
537 |
sdf.applyPattern(pattern); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
538 |
logln("pattern: \"" + pattern + "\""); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
539 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
540 |
Object[] DATA = { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
541 |
"time 10:30", new ParsePosition(10), new Date(70, Calendar.JANUARY, 1, 10, 30), |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
542 |
"time 10:x", new ParsePosition(0), null, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
543 |
"time 10x", new ParsePosition(0), null, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
544 |
}; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
545 |
for (int i=0; i<DATA.length; i+=3) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
546 |
String text = (String) DATA[i]; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
547 |
ParsePosition finish = (ParsePosition) DATA[i+1]; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
548 |
Date exp = (Date) DATA[i+2]; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
549 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
550 |
ParsePosition pos = new ParsePosition(0); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
551 |
Date d = sdf.parse(text, pos); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
552 |
logln(" text: \"" + text + "\""); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
553 |
logln(" index: " + pos.getIndex()); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
554 |
logln(" result: " + d); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
555 |
if (pos.getIndex() != finish.getIndex()) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
556 |
errln("Fail: Expected pos " + finish.getIndex()); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
557 |
if (!((d == null && exp == null) || |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
558 |
d.equals(exp))) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
559 |
errln("Fail: Expected result " + exp); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
560 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
561 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
562 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
563 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
564 |
* CANNOT REPRODUCE |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
565 |
* According to the bug report, this test should throw a |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
566 |
* StringIndexOutOfBoundsException during the second parse. However, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
567 |
* this is not seen. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
568 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
569 |
public void Test4104522() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
570 |
SimpleDateFormat sdf = new SimpleDateFormat(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
571 |
String pattern = "'time' hh:mm"; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
572 |
sdf.applyPattern(pattern); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
573 |
logln("pattern: \"" + pattern + "\""); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
574 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
575 |
// works correctly |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
576 |
ParsePosition pp = new ParsePosition(0); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
577 |
String text = "time "; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
578 |
Date date = sdf.parse(text, pp); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
579 |
logln(" text: \"" + text + "\"" + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
580 |
" date: " + date); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
581 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
582 |
// works wrong |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
583 |
pp = new ParsePosition(0); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
584 |
text = "time"; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
585 |
date = sdf.parse(text, pp); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
586 |
logln(" text: \"" + text + "\"" + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
587 |
" date: " + date); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
588 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
589 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
590 |
public void Test4106807() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
591 |
Date date; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
592 |
DateFormat df = DateFormat.getDateTimeInstance(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
593 |
Object[] data = { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
594 |
new SimpleDateFormat("yyyyMMddHHmmss"), "19980211140000", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
595 |
new SimpleDateFormat("yyyyMMddHHmmss'Z'"), "19980211140000", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
596 |
new SimpleDateFormat("yyyyMMddHHmmss''"), "19980211140000", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
597 |
new SimpleDateFormat("yyyyMMddHHmmss'a''a'"), "19980211140000a", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
598 |
new SimpleDateFormat("yyyyMMddHHmmss %"), "19980211140000 ", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
599 |
}; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
600 |
GregorianCalendar gc = new GregorianCalendar(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
601 |
TimeZone timeZone = TimeZone.getDefault(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
602 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
603 |
TimeZone gmt = (TimeZone)timeZone.clone(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
604 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
605 |
gmt.setRawOffset(0); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
606 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
607 |
for (int i=0; i<data.length; i+=2) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
608 |
SimpleDateFormat format = (SimpleDateFormat) data[i]; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
609 |
String dateString = (String) data[i+1]; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
610 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
611 |
format.setTimeZone(gmt); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
612 |
date = format.parse(dateString); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
613 |
logln(df.format(date)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
614 |
gc.setTime(date); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
615 |
logln("" + gc.get(Calendar.ZONE_OFFSET)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
616 |
logln(format.format(date)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
617 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
618 |
catch (ParseException e) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
619 |
logln("No way Jose"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
620 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
621 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
622 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
623 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
624 |
/* |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
625 |
Synopsis: Chinese time zone CTT is not recogonized correctly. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
626 |
Description: Platform Chinese Windows 95 - ** Time zone set to CST ** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
627 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
628 |
public void Test4108407() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
629 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
630 |
long l = System.currentTimeMillis(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
631 |
logln("user.timezone = " + System.getProperty("user.timezone", "?")); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
632 |
logln("Time Zone :" + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
633 |
DateFormat.getDateInstance().getTimeZone().getID()); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
634 |
logln("Default format :" + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
635 |
DateFormat.getDateInstance().format(new Date(l))); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
636 |
logln("Full format :" + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
637 |
DateFormat.getDateInstance(DateFormat.FULL).format(new |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
638 |
Date(l))); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
639 |
logln("*** Set host TZ to CST ***"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
640 |
logln("*** THE RESULTS OF THIS TEST MUST BE VERIFIED MANUALLY ***"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
641 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
642 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
643 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
644 |
* SimpleDateFormat won't parse "GMT" |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
645 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
646 |
public void Test4134203() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
647 |
String dateFormat = "MM/dd/yy HH:mm:ss zzz"; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
648 |
SimpleDateFormat fmt = new SimpleDateFormat(dateFormat); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
649 |
ParsePosition p0 = new ParsePosition(0); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
650 |
Date d = fmt.parse("01/22/92 04:52:00 GMT", p0); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
651 |
logln(d.toString()); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
652 |
// In the failure case an exception is thrown by parse(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
653 |
// if no exception is thrown, the test passes. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
654 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
655 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
656 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
657 |
* Another format for GMT string parse |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
658 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
659 |
public void Test4266432() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
660 |
String dateFormat = "MM/dd HH:mm:ss zzz yyyy"; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
661 |
SimpleDateFormat fmt = new SimpleDateFormat(dateFormat); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
662 |
ParsePosition p0 = new ParsePosition(0); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
663 |
Date d = fmt.parse("01/22 04:52:00 GMT 1992", p0); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
664 |
logln(d.toString()); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
665 |
// In the failure case an exception is thrown by parse(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
666 |
// if no exception is thrown, the test passes. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
667 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
668 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
669 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
670 |
* Millisecond field is limited to 3 digits; also test general millisecond |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
671 |
* handling. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
672 |
* |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
673 |
* NOTE: Updated for fixed semantics as of Kestrel. See |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
674 |
* 4253490 |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
675 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
676 |
public void Test4148168() throws ParseException { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
677 |
SimpleDateFormat fmt = new SimpleDateFormat("", Locale.US); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
678 |
int ms = 456; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
679 |
String[] PAT = { "S", "SS", "SSS", "SSSS", "SSSSS", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
680 |
"SSSSSSSSSSSSSSSSSSSS" }; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
681 |
String[] OUT = { "456", "456", "456", "0456", "00456", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
682 |
"00000000000000000456" }; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
683 |
Calendar cal = Calendar.getInstance(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
684 |
cal.clear(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
685 |
cal.set(Calendar.MILLISECOND, ms); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
686 |
Date d = cal.getTime(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
687 |
for (int i=0; i<OUT.length; ++i) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
688 |
fmt.applyPattern(PAT[i]); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
689 |
String str = fmt.format(d); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
690 |
if (!str.equals(OUT[i])) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
691 |
errln("FAIL: " + ms + " ms x \"" + PAT[i] + "\" -> \"" + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
692 |
str + "\", exp \"" + OUT[i] + '"'); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
693 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
694 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
695 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
696 |
// Test parsing |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
697 |
fmt.applyPattern("s.S"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
698 |
String[] IN = { "1.4", "1.04", "1.004", "1.45", "1.456", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
699 |
"1.4567", "1.45678" }; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
700 |
int[] MS = { 4, 4, 4, 45, 456, 567, 678 }; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
701 |
for (int i=0; i<IN.length; ++i) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
702 |
d = fmt.parse(IN[i]); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
703 |
cal.setTime(d); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
704 |
ms = cal.get(Calendar.MILLISECOND); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
705 |
if (ms != MS[i]) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
706 |
errln("FAIL: parse(\"" + IN[i] + "\" x \"s.S\") -> " + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
707 |
ms + " ms, exp " + MS[i] + " ms"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
708 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
709 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
710 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
711 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
712 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
713 |
* SimpleDateFormat incorrect handling of 2 single quotes in format() |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
714 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
715 |
public void Test4151631() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
716 |
String pattern = "'TO_DATE('''dd'-'MM'-'yyyy HH:mm:ss''' , ''DD-MM-YYYY HH:MI:SS'')'"; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
717 |
logln("pattern=" + pattern); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
718 |
SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.US); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
719 |
String result = format.format(new Date(1998-1900, Calendar.JUNE, 30, 13, 30, 0)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
720 |
if (!result.equals("TO_DATE('30-06-1998 13:30:00' , 'DD-MM-YYYY HH:MI:SS')")) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
721 |
errln("Fail: result=" + result); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
722 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
723 |
else { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
724 |
logln("Pass: result=" + result); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
725 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
726 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
727 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
728 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
729 |
* 'z' at end of date format throws index exception in SimpleDateFormat |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
730 |
* CANNOT REPRODUCE THIS BUG ON 1.2FCS |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
731 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
732 |
public void Test4151706() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
733 |
SimpleDateFormat fmt = |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
734 |
new SimpleDateFormat("EEEE, dd-MMM-yy HH:mm:ss z", Locale.US); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
735 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
736 |
Date d = fmt.parse("Thursday, 31-Dec-98 23:00:00 GMT"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
737 |
if (d.getTime() != Date.UTC(1998-1900, Calendar.DECEMBER, 31, 23, 0, 0)) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
738 |
errln("Incorrect value: " + d); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
739 |
} catch (Exception e) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
740 |
errln("Fail: " + e); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
741 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
742 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
743 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
744 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
745 |
* SimpleDateFormat fails to parse redundant data. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
746 |
* This is actually a bug down in GregorianCalendar, but it was reported |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
747 |
* as follows... |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
748 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
749 |
public void Test4153860() throws ParseException { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
750 |
Locale savedLocale = Locale.getDefault(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
751 |
Locale.setDefault(Locale.US); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
752 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
753 |
SimpleDateFormat sf = (SimpleDateFormat)DateFormat.getDateTimeInstance(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
754 |
// Set the pattern |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
755 |
sf.applyPattern("yyyy.MM-dd"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
756 |
// Try to create a Date for February 4th |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
757 |
Date d1 = sf.parse("1998.02-04"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
758 |
// Set the pattern, this time to use the W value |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
759 |
sf.applyPattern("yyyy.MM-dd W"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
760 |
// Try to create a Date for February 4th |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
761 |
Date d2 = sf.parse("1998.02-04 1"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
762 |
if (!d1.equals(d2)) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
763 |
errln("Parse failed, got " + d2 + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
764 |
", expected " + d1); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
765 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
766 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
767 |
finally { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
768 |
Locale.setDefault(savedLocale); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
769 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
770 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
771 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
772 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
773 |
* Confirm that "EST"(GMT-5:00) and "CST"(GMT-6:00) are used in US |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
774 |
* as "EST" or "CST", not Australian "EST" and "CST". |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
775 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
776 |
public void Test4406615() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
777 |
Locale savedLocale = Locale.getDefault(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
778 |
TimeZone savedTimeZone = TimeZone.getDefault(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
779 |
Locale.setDefault(Locale.US); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
780 |
TimeZone.setDefault(TimeZone.getTimeZone("PST")); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
781 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
782 |
Date d1, d2; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
783 |
String dt = "Mon, 1 Jan 2001 00:00:00"; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
784 |
SimpleDateFormat sdf = |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
785 |
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
786 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
787 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
788 |
d1 = sdf.parse(dt+" EST"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
789 |
d2 = sdf.parse(dt+" CST"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
790 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
791 |
if (d1.getYear() != (2000-1900) || d1.getMonth() != 11 || |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
792 |
d1.getDate() != 31 || d1.getHours() != 21 || d1.getMinutes() != 0 || |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
793 |
d2.getYear() != (2000-1900) || d2.getMonth() != 11 || |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
794 |
d2.getDate() != 31 || d2.getHours() != 22 || d2.getMinutes() != 0) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
795 |
errln("Parse failed, d1 = " + d1 + ", d2 = " + d2); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
796 |
} else { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
797 |
logln("Parse passed"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
798 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
799 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
800 |
catch (Exception e) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
801 |
errln("Parse failed, got Exception " + e); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
802 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
803 |
finally { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
804 |
Locale.setDefault(savedLocale); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
805 |
TimeZone.setDefault(savedTimeZone); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
806 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
807 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
808 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
809 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
810 |
* Cannot reproduce this bug under 1.2 FCS -- it may be a convoluted duplicate |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
811 |
* of some other bug that has been fixed. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
812 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
813 |
public void Test4162071() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
814 |
String dateString = "Thu, 30-Jul-1999 11:51:14 GMT"; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
815 |
String format = "EEE', 'dd-MMM-yyyy HH:mm:ss z"; // RFC 822/1123 |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
816 |
SimpleDateFormat df = new |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
817 |
SimpleDateFormat(format, Locale.US); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
818 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
819 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
820 |
Date x = df.parse(dateString); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
821 |
logln("Parse format \"" + format + "\" ok"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
822 |
logln(dateString + " -> " + df.format(x)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
823 |
} catch (Exception e) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
824 |
errln("Parse format \"" + format + "\" failed."); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
825 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
826 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
827 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
828 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
829 |
* DateFormat shouldn't parse year "-1" as a two-digit year (e.g., "-1" -> 1999). |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
830 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
831 |
public void Test4182066() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
832 |
Locale savedLocale = Locale.getDefault(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
833 |
Locale.setDefault(Locale.US); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
834 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
835 |
SimpleDateFormat fmt = new SimpleDateFormat("MM/dd/yy", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
836 |
DateFormatSymbols.getInstance(Locale.US)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
837 |
SimpleDateFormat dispFmt = new SimpleDateFormat("MMM dd yyyy GG", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
838 |
DateFormatSymbols.getInstance(Locale.US)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
839 |
/* We expect 2-digit year formats to put 2-digit years in the right |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
840 |
* window. Out of range years, that is, anything less than "00" or |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
841 |
* greater than "99", are treated as literal years. So "1/2/3456" |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
842 |
* becomes 3456 AD. Likewise, "1/2/-3" becomes -3 AD == 2 BC. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
843 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
844 |
Object[] DATA = { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
845 |
"02/29/00", new Date(2000-1900, Calendar.FEBRUARY, 29), |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
846 |
"01/23/01", new Date(2001-1900, Calendar.JANUARY, 23), |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
847 |
"04/05/-1", new Date( -1-1900, Calendar.APRIL, 5), |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
848 |
"01/23/-9", new Date( -9-1900, Calendar.JANUARY, 23), |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
849 |
"11/12/1314", new Date(1314-1900, Calendar.NOVEMBER, 12), |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
850 |
"10/31/1", new Date( 1-1900, Calendar.OCTOBER, 31), |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
851 |
"09/12/+1", null, // "+1" isn't recognized by US NumberFormat |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
852 |
"09/12/001", new Date( 1-1900, Calendar.SEPTEMBER,12), |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
853 |
}; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
854 |
StringBuffer out = new StringBuffer(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
855 |
boolean pass = true; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
856 |
for (int i=0; i<DATA.length; i+=2) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
857 |
String str = (String) DATA[i]; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
858 |
Date expected = (Date) DATA[i+1]; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
859 |
Date actual; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
860 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
861 |
actual = fmt.parse(str); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
862 |
} catch (ParseException e) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
863 |
actual = null; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
864 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
865 |
String actStr = actual != null |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
866 |
? dispFmt.format(actual) : String.valueOf(actual); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
867 |
if (expected == actual |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
868 |
|| (expected != null && expected.equals(actual))) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
869 |
out.append(str + " => " + actStr + "\n"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
870 |
} else { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
871 |
String expStr = expected != null |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
872 |
? dispFmt.format(expected) : String.valueOf(expected); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
873 |
out.append("FAIL: " + str + " => " + actStr |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
874 |
+ ", expected " + expStr + "\n"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
875 |
pass = false; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
876 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
877 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
878 |
if (pass) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
879 |
log(out.toString()); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
880 |
} else { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
881 |
err(out.toString()); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
882 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
883 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
884 |
finally { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
885 |
Locale.setDefault(savedLocale); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
886 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
887 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
888 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
889 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
890 |
* Bug 4210209 |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
891 |
* Bug 4209272 |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
892 |
* DateFormat cannot parse Feb 29 2000 when setLenient(false) |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
893 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
894 |
public void Test4210209() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
895 |
String pattern = "MMM d, yyyy"; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
896 |
DateFormat fmt = new SimpleDateFormat(pattern, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
897 |
DateFormatSymbols.getInstance(Locale.US)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
898 |
fmt.getCalendar().setLenient(false); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
899 |
Date d = new Date(2000-1900, Calendar.FEBRUARY, 29); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
900 |
String s = fmt.format(d); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
901 |
logln(d + " x " + pattern + " => " + s); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
902 |
ParsePosition pos = new ParsePosition(0); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
903 |
d = fmt.parse(s, pos); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
904 |
logln(d + " <= " + pattern + " x " + s); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
905 |
logln("Parse pos = " + pos); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
906 |
if (pos.getErrorIndex() != -1) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
907 |
errln("FAIL"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
908 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
909 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
910 |
// The underlying bug is in GregorianCalendar. If the following lines |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
911 |
// succeed, the bug is fixed. If the bug isn't fixed, they will throw |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
912 |
// an exception. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
913 |
GregorianCalendar cal = new GregorianCalendar(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
914 |
cal.clear(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
915 |
cal.setLenient(false); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
916 |
cal.set(2000, Calendar.FEBRUARY, 29); // This should work! |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
917 |
logln(cal.getTime().toString()); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
918 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
919 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
920 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
921 |
* DateFormat.getDateTimeInstance() allows illegal parameters. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
922 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
923 |
public void Test4213086() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
924 |
int[] DATA = { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
925 |
// Style value, 0/1 for illegal/legal |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
926 |
-99, 0, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
927 |
-1, 0, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
928 |
0, 1, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
929 |
1, 1, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
930 |
2, 1, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
931 |
3, 1, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
932 |
4, 0, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
933 |
99, 0, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
934 |
}; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
935 |
String[] DESC = { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
936 |
"getDateTimeInstance(date)", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
937 |
"getDateTimeInstance(time)", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
938 |
"getDateInstance", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
939 |
"getTimeInstance", |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
940 |
}; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
941 |
String[] GOT = { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
942 |
"disallowed", "allowed", "<invalid>" |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
943 |
}; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
944 |
for (int i=0; i<DATA.length; i+=2) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
945 |
int got = 2; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
946 |
for (int j=0; j<4; ++j) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
947 |
Exception e = null; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
948 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
949 |
DateFormat df; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
950 |
switch (j) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
951 |
case 0: |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
952 |
df = DateFormat.getDateTimeInstance(DATA[i], 0); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
953 |
break; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
954 |
case 1: |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
955 |
df = DateFormat.getDateTimeInstance(0, DATA[i]); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
956 |
break; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
957 |
case 2: |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
958 |
df = DateFormat.getDateInstance(DATA[i]); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
959 |
break; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
960 |
case 3: |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
961 |
df = DateFormat.getTimeInstance(DATA[i]); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
962 |
break; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
963 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
964 |
got = 1; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
965 |
} catch (IllegalArgumentException iae) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
966 |
got = 0; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
967 |
} catch (Exception ex) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
968 |
e = ex; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
969 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
970 |
if (got != DATA[i+1] || e != null) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
971 |
errln("FAIL: DateFormat." + DESC[j] + " style " + DATA[i] + " " + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
972 |
(e != null ? e.toString() : GOT[got])); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
973 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
974 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
975 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
976 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
977 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
978 |
public void Test4253490() throws ParseException { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
979 |
SimpleDateFormat fmt = new SimpleDateFormat("S", Locale.US); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
980 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
981 |
GregorianCalendar cal = new GregorianCalendar(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
982 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
983 |
int FORMAT_MS = 12; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
984 |
String[] FORMAT_PAT = { "S", "SS", "SSS", "SSSS" }; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
985 |
String[] FORMAT_TO = { "12", "12", "012", "0012" }; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
986 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
987 |
String PARSE_PAT = "S"; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
988 |
String[] PARSE_STR = { "1", "12", "125", "1250" }; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
989 |
int[] PARSE_TO = { 1, 12, 125, 250 }; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
990 |
String PARSE_LPAT = "SSSSS"; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
991 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
992 |
// Test formatting. We want to make sure all digits are output |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
993 |
// and that they are zero-padded on the left if necessary. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
994 |
cal.setTime(new Date(0L)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
995 |
cal.set(Calendar.MILLISECOND, FORMAT_MS); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
996 |
Date d = cal.getTime(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
997 |
for (int i=0; i<FORMAT_PAT.length; ++i) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
998 |
fmt.applyPattern(FORMAT_PAT[i]); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
999 |
String s = fmt.format(d); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1000 |
if (s.equals(FORMAT_TO[i])) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1001 |
logln(String.valueOf(FORMAT_MS) + " ms f* \"" + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1002 |
FORMAT_PAT[i] + "\" -> \"" + s + '"'); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1003 |
} else { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1004 |
errln("FAIL: " + FORMAT_MS + " ms f* \"" + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1005 |
FORMAT_PAT[i] + "\" -> \"" + s + "\", expect \"" + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1006 |
FORMAT_TO[i] + '"'); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1007 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1008 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1009 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1010 |
// Test parsing. We want to make sure all digits are read. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1011 |
fmt.applyPattern(PARSE_PAT); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1012 |
for (int i=0; i<PARSE_STR.length; ++i) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1013 |
cal.setTime(fmt.parse(PARSE_STR[i])); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1014 |
int ms = cal.get(Calendar.MILLISECOND); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1015 |
if (ms == PARSE_TO[i]) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1016 |
logln("\"" + PARSE_STR[i] + "\" p* \"" + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1017 |
PARSE_PAT + "\" -> " + ms + " ms"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1018 |
} else { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1019 |
errln("FAIL: \"" + PARSE_STR[i] + "\" p* \"" + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1020 |
PARSE_PAT + "\" -> " + ms + " ms, expect " + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1021 |
PARSE_TO[i] + " ms"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1022 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1023 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1024 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1025 |
// Test LONG parsing. We want to make sure all digits are read. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1026 |
fmt.applyPattern(PARSE_LPAT); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1027 |
for (int i=0; i<PARSE_STR.length; ++i) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1028 |
cal.setTime(fmt.parse(PARSE_STR[i])); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1029 |
int ms = cal.get(Calendar.MILLISECOND); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1030 |
if (ms == PARSE_TO[i]) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1031 |
logln("\"" + PARSE_STR[i] + "\" p* \"" + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1032 |
PARSE_LPAT + "\" -> " + ms + " ms"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1033 |
} else { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1034 |
errln("FAIL: \"" + PARSE_STR[i] + "\" p* \"" + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1035 |
PARSE_LPAT + "\" -> " + ms + " ms, expect " + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1036 |
PARSE_TO[i] + " ms"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1037 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1038 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1039 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1040 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1041 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1042 |
* Bug in handling of time instance; introduces in fix for 4213086. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1043 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1044 |
public void Test4250359() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1045 |
DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1046 |
Locale.US); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1047 |
Date d = new Date(1999-1900, Calendar.DECEMBER, 25, |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1048 |
1, 2, 3); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1049 |
String s = df.format(d); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1050 |
// If the bug is present, we see "1:02 AM 1:02 AM". |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1051 |
// Look for more than one instance of "AM". |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1052 |
int i = s.indexOf("AM"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1053 |
int j = s.indexOf("AM", i+1); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1054 |
if (i < 0 || j >= 0) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1055 |
errln("FAIL: getTimeInstance().format(d) => \"" + |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1056 |
s + "\""); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1057 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1058 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1059 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1060 |
/** |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1061 |
* Test whether SimpleDataFormat (DateFormatSymbols) can format/parse |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1062 |
* non-localized time zones. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1063 |
*/ |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1064 |
public void Test4261506() { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1065 |
Locale savedLocale = Locale.getDefault(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1066 |
TimeZone savedTimeZone = TimeZone.getDefault(); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1067 |
Locale.setDefault(Locale.JAPAN); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1068 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1069 |
// XXX: Test assumes "PST" is not TimeZoneNames_ja. Need to |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1070 |
// pick up another time zone when L10N is done to that file. |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1071 |
TimeZone.setDefault(TimeZone.getTimeZone("PST")); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1072 |
SimpleDateFormat fmt = new SimpleDateFormat("yy/MM/dd hh:ss zzz", Locale.JAPAN); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1073 |
String result = fmt.format(new Date(1999, 0, 1)); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1074 |
logln("format()=>" + result); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1075 |
if (!result.endsWith("PST")) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1076 |
errln("FAIL: SimpleDataFormat.format() did not retrun PST"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1077 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1078 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1079 |
Date d = null; |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1080 |
try { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1081 |
d = fmt.parse("99/1/1 10:10 PST"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1082 |
} catch (ParseException e) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1083 |
errln("FAIL: SimpleDataFormat.parse() could not parse PST"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1084 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1085 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1086 |
result = fmt.format(d); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1087 |
logln("roundtrip:" + result); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1088 |
if (!result.equals("99/01/01 10:10 PST")) { |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1089 |
errln("FAIL: SimpleDataFomat timezone roundtrip failed"); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1090 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1091 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1092 |
Locale.setDefault(savedLocale); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1093 |
TimeZone.setDefault(savedTimeZone); |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1094 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1095 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1096 |
} |
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1097 |
|
e761c1ccd13e
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff
changeset
|
1098 |
//eof |