Path: blob/master/test/jdk/java/text/Format/DateFormat/TestDayPeriodWithSDF.java
41152 views
/*1* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22/*23* @test24* @bug 820917525* @summary Checks the 'B' character added in the CLDR date-time patterns is26* getting resolved with 'a' character (am/pm strings) for burmese locale.27* This test case assumes that the 'B' character is added in CLDRv33 update28* for burmese locale in the time patterns. Since it is not supported by29* SimpleDateFormat it is replaced with the 'a' while CLDR resource30* conversion.31* @modules jdk.localedata32* @run testng/othervm TestDayPeriodWithSDF33*/3435import org.testng.annotations.DataProvider;36import org.testng.annotations.Test;37import static org.testng.Assert.*;3839import java.text.DateFormat;40import java.util.Calendar;41import java.util.Date;42import java.util.GregorianCalendar;43import java.util.Locale;4445public class TestDayPeriodWithSDF {4647private static final Locale BURMESE = new Locale("my");48private static final DateFormat FORMAT_SHORT_BURMESE = DateFormat.getTimeInstance(DateFormat.SHORT, BURMESE);49private static final DateFormat FORMAT_MEDIUM_BURMESE = DateFormat.getTimeInstance(DateFormat.MEDIUM, BURMESE);5051private static final Date DATE_AM = new GregorianCalendar(2019, Calendar.FEBRUARY, 14, 10, 10, 10).getTime();52private static final Date DATE_PM = new GregorianCalendar(2019, Calendar.FEBRUARY, 14, 12, 12, 12).getTime();5354@DataProvider(name = "timePatternData")55Object[][] timePatternData() {56return new Object[][] {57{FORMAT_SHORT_BURMESE, DATE_AM, "\u1014\u1036\u1014\u1000\u103A \u1041\u1040:\u1041\u1040"},58{FORMAT_SHORT_BURMESE, DATE_PM, "\u100A\u1014\u1031 \u1041\u1042:\u1041\u1042"},59{FORMAT_MEDIUM_BURMESE, DATE_AM, "\u1014\u1036\u1014\u1000\u103A \u1041\u1040:\u1041\u1040:\u1041\u1040"},60{FORMAT_MEDIUM_BURMESE, DATE_PM, "\u100A\u1014\u1031 \u1041\u1042:\u1041\u1042:\u1041\u1042"},61};62}6364@Test(dataProvider = "timePatternData")65public void testTimePattern(DateFormat format, Date date, String expected) {66String actual = format.format(date);67assertEquals(actual, expected);68}6970}717273