1 /*
2  * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
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  *
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.
22  */
23 /*
24  * @test
25  * @bug 8209175
26  * @summary Checks the 'B' character added in the CLDR date-time patterns is
27  *          getting resolved with 'a' character (am/pm strings) for burmese locale.
28  *          This test case assumes that the 'B' character is added in CLDRv33 update
29  *          for burmese locale in the time patterns. Since it is not supported by
30  *          SimpleDateFormat it is replaced with the 'a' while CLDR resource
31  *          conversion.
32  * @modules jdk.localedata
33  * @run testng/othervm TestDayPeriodWithSDF
34  */
35 
36 import org.testng.annotations.DataProvider;
37 import org.testng.annotations.Test;
38 import static org.testng.Assert.*;
39 
40 import java.text.DateFormat;
41 import java.util.Calendar;
42 import java.util.Date;
43 import java.util.GregorianCalendar;
44 import java.util.Locale;
45 
46 public class TestDayPeriodWithSDF {
47 
48     private static final Locale BURMESE = new Locale("my");
49     private static final DateFormat FORMAT_SHORT_BURMESE = DateFormat.getTimeInstance(DateFormat.SHORT, BURMESE);
50     private static final DateFormat FORMAT_MEDIUM_BURMESE = DateFormat.getTimeInstance(DateFormat.MEDIUM, BURMESE);
51 
52     private static final Date DATE_AM = new GregorianCalendar(2019, Calendar.FEBRUARY, 14, 10, 10, 10).getTime();
53     private static final Date DATE_PM = new GregorianCalendar(2019, Calendar.FEBRUARY, 14, 12, 12, 12).getTime();
54 
55     @DataProvider(name = "timePatternData")
timePatternData()56     Object[][] timePatternData() {
57         return new Object[][] {
58                 {FORMAT_SHORT_BURMESE, DATE_AM, "\u1014\u1036\u1014\u1000\u103A \u1041\u1040:\u1041\u1040"},
59                 {FORMAT_SHORT_BURMESE, DATE_PM, "\u100A\u1014\u1031 \u1041\u1042:\u1041\u1042"},
60                 {FORMAT_MEDIUM_BURMESE, DATE_AM, "\u1014\u1036\u1014\u1000\u103A \u1041\u1040:\u1041\u1040:\u1041\u1040"},
61                 {FORMAT_MEDIUM_BURMESE, DATE_PM, "\u100A\u1014\u1031 \u1041\u1042:\u1041\u1042:\u1041\u1042"},
62         };
63     }
64 
65     @Test(dataProvider = "timePatternData")
testTimePattern(DateFormat format, Date date, String expected)66     public void testTimePattern(DateFormat format, Date date, String expected) {
67         String actual = format.format(date);
68         assertEquals(actual, expected);
69     }
70 
71 }
72