author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 7787 | jdk/test/java/util/PluggableLocale/providersrc/DateFormatProviderImpl.java@d2420a14d0a2 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
7787
d2420a14d0a2
7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2 | 22 |
*/ |
23 |
/* |
|
24 |
* |
|
25 |
*/ |
|
26 |
||
27 |
package com.foo; |
|
28 |
||
29 |
import java.text.*; |
|
30 |
import java.text.spi.*; |
|
31 |
import java.util.*; |
|
32 |
||
33 |
import com.foobar.Utils; |
|
34 |
||
35 |
public class DateFormatProviderImpl extends DateFormatProvider { |
|
36 |
||
37 |
static Locale[] avail = { |
|
38 |
Locale.JAPAN, |
|
39 |
new Locale("ja", "JP", "osaka"), |
|
40 |
new Locale("ja", "JP", "kyoto"), |
|
41 |
new Locale("yy")}; |
|
42 |
||
43 |
static String[] datePattern = { |
|
44 |
"yyyy'\u5e74'M'\u6708'd'\u65e5'", // full date pattern |
|
7787
d2420a14d0a2
7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents:
5506
diff
changeset
|
45 |
"yyyy/MMM/dd", // long date pattern |
2 | 46 |
"yyyy/MM/dd", // medium date pattern |
47 |
"yy/MM/dd" // short date pattern |
|
48 |
}; |
|
49 |
||
50 |
static String[] timePattern = { |
|
51 |
"H'\u6642'mm'\u5206'ss'\u79d2' z", // full time pattern |
|
52 |
"H:mm:ss z", // long time pattern |
|
53 |
"H:mm:ss", // medium time pattern |
|
54 |
"H:mm" // short time pattern |
|
55 |
}; |
|
56 |
||
57 |
static String[] dialect = { |
|
58 |
"\u3067\u3059\u3002", |
|
59 |
"\u3084\u3002", |
|
60 |
"\u3069\u3059\u3002", |
|
61 |
"\u308f\u3044\u308f\u3044" |
|
62 |
}; |
|
63 |
||
64 |
public Locale[] getAvailableLocales() { |
|
65 |
return avail; |
|
66 |
} |
|
67 |
||
68 |
public DateFormat getDateInstance(int style, Locale locale) { |
|
69 |
for (int i = 0; i < avail.length; i ++) { |
|
70 |
if (Utils.supportsLocale(avail[i], locale)) { |
|
7787
d2420a14d0a2
7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents:
5506
diff
changeset
|
71 |
return new FooDateFormat(datePattern[style]+dialect[i], locale); |
2 | 72 |
} |
73 |
} |
|
74 |
throw new IllegalArgumentException("locale is not supported: "+locale); |
|
75 |
} |
|
76 |
||
77 |
public DateFormat getTimeInstance(int style, Locale locale) { |
|
78 |
for (int i = 0; i < avail.length; i ++) { |
|
79 |
if (Utils.supportsLocale(avail[i], locale)) { |
|
7787
d2420a14d0a2
7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents:
5506
diff
changeset
|
80 |
return new FooDateFormat(timePattern[style]+dialect[i], locale); |
2 | 81 |
} |
82 |
} |
|
83 |
throw new IllegalArgumentException("locale is not supported: "+locale); |
|
84 |
} |
|
85 |
||
86 |
public DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale locale) { |
|
87 |
for (int i = 0; i < avail.length; i ++) { |
|
88 |
if (Utils.supportsLocale(avail[i], locale)) { |
|
7787
d2420a14d0a2
7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents:
5506
diff
changeset
|
89 |
return new FooDateFormat( |
2 | 90 |
datePattern[dateStyle]+" "+timePattern[timeStyle]+dialect[i], locale); |
91 |
} |
|
92 |
} |
|
93 |
throw new IllegalArgumentException("locale is not supported: "+locale); |
|
94 |
} |
|
95 |
} |