8080774: DateFormat for Singapore/English locale (en_SG) is M/d/yy instead of d/M/yy
authoraefimov
Mon, 08 Jun 2015 16:17:37 +0300
changeset 31062 a6b5f444cb68
parent 31061 fead7d86d75f
child 31063 4338d96ed321
child 31077 9ea0449a6ec5
child 31080 00a25f4c4d44
child 31174 f3e2593f91cc
8080774: DateFormat for Singapore/English locale (en_SG) is M/d/yy instead of d/M/yy Reviewed-by: naoto
jdk/src/java.base/share/classes/sun/text/resources/en/FormatData_en_SG.java
jdk/test/java/text/Format/DateFormat/LocaleDateFormats.java
jdk/test/sun/text/resources/LocaleData
jdk/test/sun/text/resources/LocaleDataTest.java
--- a/jdk/src/java.base/share/classes/sun/text/resources/en/FormatData_en_SG.java	Mon Jun 08 16:37:53 2015 +0400
+++ b/jdk/src/java.base/share/classes/sun/text/resources/en/FormatData_en_SG.java	Mon Jun 08 16:17:37 2015 +0300
@@ -88,6 +88,14 @@
                     "NaN",
                 }
             },
+            { "DatePatterns",
+                new String[] {
+                    "EEEE, d MMMM, yyyy", // full date pattern
+                    "d MMMM, yyyy",       // long date pattern
+                    "d MMM, yyyy",        // medium date pattern
+                    "d/M/yy",             // short date pattern
+                }
+            },
         };
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/text/Format/DateFormat/LocaleDateFormats.java	Mon Jun 08 16:17:37 2015 +0300
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8080774
+ * @run testng/othervm -Djava.locale.providers=JRE,CLDR LocaleDateFormats
+ * @summary This file contains tests for JRE locales date formats
+ */
+
+import java.text.DateFormat;
+import java.util.Calendar;
+import java.util.Locale;
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+public class LocaleDateFormats {
+
+    @Test(dataProvider = "dateFormats")
+    public void testDateFormat(Locale loc, int style, int year, int month, int date, String expectedString) {
+        Calendar cal = Calendar.getInstance(loc);
+        cal.set(year, month-1, date);
+        // Create date formatter based on requested style and test locale
+        DateFormat df = DateFormat.getDateInstance(style, loc);
+        // Test the date format
+        assertEquals(df.format(cal.getTime()), expectedString);
+    }
+
+    @DataProvider(name = "dateFormats" )
+    private Object[][] dateFormats() {
+        return new Object[][] {
+            //8080774
+            //Locale, Format type, year, month, date, expected result
+            {localeEnSG, DateFormat.SHORT, 2015, 5, 6, "6/5/15"},
+            {localeEnSG, DateFormat.MEDIUM, 2015, 5, 6, "6 May, 2015"},
+            {localeEnSG, DateFormat.LONG, 2015, 5, 6, "6 May, 2015"},
+            {localeEnSG, DateFormat.FULL, 2015, 5, 6, "Wednesday, 6 May, 2015"}
+        };
+    }
+    // en_SG Locale instance
+    private static final Locale localeEnSG = new Locale("en", "SG");
+}
--- a/jdk/test/sun/text/resources/LocaleData	Mon Jun 08 16:37:53 2015 +0400
+++ b/jdk/test/sun/text/resources/LocaleData	Mon Jun 08 16:17:37 2015 +0300
@@ -5414,11 +5414,13 @@
 FormatData/en_SG/TimePatterns/1=h:mm:ss a z
 FormatData/en_SG/TimePatterns/2=h:mm:ss a
 FormatData/en_SG/TimePatterns/3=h:mm a
-FormatData/en_SG/DatePatterns/0=EEEE, MMMM d, yyyy
-FormatData/en_SG/DatePatterns/1=MMMM d, yyyy
-FormatData/en_SG/DatePatterns/2=MMM d, yyyy
-FormatData/en_SG/DatePatterns/3=M/d/yy
 FormatData/en_SG/DateTimePatterns/0={1} {0}
+# bug# 8080774
+# Day should precede month for all date formats in en_SG - CLDR 27.0.0
+FormatData/en_SG/DatePatterns/0=EEEE, d MMMM, yyyy
+FormatData/en_SG/DatePatterns/1=d MMMM, yyyy
+FormatData/en_SG/DatePatterns/2=d MMM, yyyy
+FormatData/en_SG/DatePatterns/3=d/M/yy
 # Use approved data
 FormatData/ms/Eras/0=BCE
 FormatData/ms/Eras/1=CE
--- a/jdk/test/sun/text/resources/LocaleDataTest.java	Mon Jun 08 16:37:53 2015 +0400
+++ b/jdk/test/sun/text/resources/LocaleDataTest.java	Mon Jun 08 16:17:37 2015 +0300
@@ -36,7 +36,7 @@
  *      6919624 6998391 7019267 7020960 7025837 7020583 7036905 7066203 7101495
  *      7003124 7085757 7028073 7171028 7189611 8000983 7195759 8004489 8006509
  *      7114053 7074882 7040556 8013836 8021121 6192407 6931564 8027695 8017142
- *      8037343 8055222 8042126 8074791 8075173
+ *      8037343 8055222 8042126 8074791 8075173 8080774
  * @summary Verify locale data
  *
  */