]> granicus.if.org Git - icu/commitdiff
ICU-9984 (J) For DTPG, Y in skeleton should produce Y in pattern
authorPeter Edberg <pedberg@unicode.org>
Thu, 27 Jun 2013 06:16:33 +0000 (06:16 +0000)
committerPeter Edberg <pedberg@unicode.org>
Thu, 27 Jun 2013 06:16:33 +0000 (06:16 +0000)
X-SVN-Rev: 33857

icu4j/main/classes/core/src/com/ibm/icu/text/DateTimePatternGenerator.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateTimeGeneratorTest.java

index 955a51ef5f7e6ad1aa3f0042cca7c3e793b7313a..9798e98551553e341ed80aec38710f30864d0e37 100644 (file)
@@ -1747,7 +1747,8 @@ public class DateTimePatternGenerator implements Freezable<DateTimePatternGenera
                             adjFieldLen = fieldBuilder.length();
                         }
                     }
-                    char c = (type != HOUR && type != MONTH && type != WEEKDAY && type != YEAR)? reqField.charAt(0): fieldBuilder.charAt(0);
+                    char c = (type != HOUR && type != MONTH && type != WEEKDAY && (type != YEAR || reqField.charAt(0)=='Y'))?
+                                reqField.charAt(0): fieldBuilder.charAt(0);
                     fieldBuilder = new StringBuilder();
                     for (int i = adjFieldLen; i > 0; --i) fieldBuilder.append(c);
                 }
index 78611cbbcfa9c2ca3a993427ef52e2cbf3583d14..98d6dbffec36e9621bd95e9611aafe6abb3405a1 100644 (file)
@@ -1167,6 +1167,16 @@ public class DateTimeGeneratorTest extends TestFmwk {
               new TestOptionsItem( "be", "Hmm",  "H.mm",    DateTimePatternGenerator.MATCH_HOUR_FIELD_LENGTH ),
               new TestOptionsItem( "be", "HHmm", "HH.mm",   DateTimePatternGenerator.MATCH_HOUR_FIELD_LENGTH ),
               new TestOptionsItem( "be", "hhmm", "hh.mm a", DateTimePatternGenerator.MATCH_HOUR_FIELD_LENGTH ),
+              //
+              new TestOptionsItem( "en",                   "yyyy", "yyyy", DateTimePatternGenerator.MATCH_NO_OPTIONS ),
+              new TestOptionsItem( "en",                   "YYYY", "YYYY", DateTimePatternGenerator.MATCH_NO_OPTIONS ),
+              new TestOptionsItem( "en",                   "U",    "y",    DateTimePatternGenerator.MATCH_NO_OPTIONS ),
+              new TestOptionsItem( "en@calendar=japanese", "yyyy", "y G",  DateTimePatternGenerator.MATCH_NO_OPTIONS ),
+              new TestOptionsItem( "en@calendar=japanese", "YYYY", "Y G",  DateTimePatternGenerator.MATCH_NO_OPTIONS ),
+              new TestOptionsItem( "en@calendar=japanese", "U",    "y G",  DateTimePatternGenerator.MATCH_NO_OPTIONS ),
+              new TestOptionsItem( "en@calendar=chinese",  "yyyy", "U",    DateTimePatternGenerator.MATCH_NO_OPTIONS ),
+              new TestOptionsItem( "en@calendar=chinese",  "YYYY", "Y",    DateTimePatternGenerator.MATCH_NO_OPTIONS ),
+              new TestOptionsItem( "en@calendar=chinese",  "U",    "U",    DateTimePatternGenerator.MATCH_NO_OPTIONS ),
           };
 
           for (int i = 0; i < testOptionsData.length; ++i) {