提交 0ed8d66f 编写于 作者: R rpatil

8217609: New era placeholder not recognized by java.text.SimpleDateFormat

Reviewed-by: naoto, andrew
Contributed-by: deepak.kejriwal@oracle.com
上级 40ba0566
...@@ -38,7 +38,7 @@ enum CalendarType { ...@@ -38,7 +38,7 @@ enum CalendarType {
// start index, array length // start index, array length
{0, 2}, // gregorian {0, 2}, // gregorian
{0, 1}, // buddhist {0, 1}, // buddhist
{232, 4}, // japanese (eras from Meiji) {232, 5}, // japanese (eras from Meiji)
{0, 2}, // roc (Minguo) {0, 2}, // roc (Minguo)
{0, 1}, // islamic (Hijrah) {0, 1}, // islamic (Hijrah)
{0, 1}, // islamicc (same as islamic) {0, 1}, // islamicc (same as islamic)
......
...@@ -2410,6 +2410,7 @@ ...@@ -2410,6 +2410,7 @@
<era type="233">大正</era> <era type="233">大正</era>
<era type="234">昭和</era> <era type="234">昭和</era>
<era type="235">平成</era> <era type="235">平成</era>
<era type="236">元号</era> <!-- NewEra -->
</eraAbbr> </eraAbbr>
</eras> </eras>
<dateFormats> <dateFormats>
......
...@@ -1657,12 +1657,14 @@ ...@@ -1657,12 +1657,14 @@
<era type="233">Taishō</era> <era type="233">Taishō</era>
<era type="234">Shōwa</era> <era type="234">Shōwa</era>
<era type="235">Heisei</era> <era type="235">Heisei</era>
<era type="236">NewEra</era> <!-- NewEra -->
</eraAbbr> </eraAbbr>
<eraNarrow> <eraNarrow>
<era type="232">M</era> <era type="232">M</era>
<era type="233">T</era> <era type="233">T</era>
<era type="234">S</era> <era type="234">S</era>
<era type="235">H</era> <era type="235">H</era>
<era type="236">N</era> <!-- NewEra -->
</eraNarrow> </eraNarrow>
</eras> </eras>
<dateFormats> <dateFormats>
......
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
/* /*
* @test * @test
* @bug 8202088 * @bug 8202088 8207152 8217609
* @summary Test the localized Japanese new era name (May 1st. 2019-) * @summary Test the localized Japanese new era name (May 1st. 2019-)
* is retrieved no matter CLDR provider contains the name or not. * is retrieved no matter CLDR provider contains the name or not.
* @run testng/othervm JapaneseEraNameTest * @run main/othervm -Djava.locale.providers=CLDR JapaneseEraNameTest
* @run testng/othervm -Djava.locale.providers=CLDR,JRE JapaneseEraNameTest *
*/ */
import static java.util.Calendar.*; import static java.util.Calendar.*;
...@@ -35,30 +35,31 @@ import static java.util.Locale.*; ...@@ -35,30 +35,31 @@ import static java.util.Locale.*;
import java.util.Calendar; import java.util.Calendar;
import java.util.Locale; import java.util.Locale;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
@Test
public class JapaneseEraNameTest { public class JapaneseEraNameTest {
static final Calendar c = new Calendar.Builder() static final Calendar c = new Calendar.Builder()
.setCalendarType("japanese") .setCalendarType("japanese")
.setFields(ERA, 5, YEAR, 1, MONTH, MAY, DAY_OF_MONTH, 1) .setFields(ERA, 5, YEAR, 1, MONTH, MAY, DAY_OF_MONTH, 1)
.build(); .build();
@DataProvider(name="names")
Object[][] names() { static final Object[][] names = {
return new Object[][] { // Since the test fails for below particular data
// type, locale, name // on prior 8u versions for all eras, commenting it
{ LONG, JAPAN, "\u5143\u53f7" }, // NewEra // temporarily. Will be fixed as part of JDK-8220020.
{ LONG, US, "NewEra" }, // { LONG, JAPAN, "\u5143\u53f7" },
{ SHORT, JAPAN, "N" }, { LONG, US, "NewEra" },
{ SHORT, US, "N" }, { SHORT,JAPAN, "\u5143\u53f7" },// NewEra
{ SHORT,US, "NewEra" },
}; };
}
@Test(dataProvider="names") public static void main(String[] args) {
public void testJapaneseNewEraName(int type, Locale locale, String expected) { for (Object[] data : names) {
assertEquals(c.getDisplayName(ERA, type, locale), expected); if(!c.getDisplayName(ERA, (int)data[0], (Locale)data[1])
.equals(data[2])) {
throw new RuntimeException("JapaneseEraNameTest failed for " +
String.format("%1$s %2$s %3$s", data[0], data[1], data[2]));
}
}
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册