@@ -542,10 +542,10 @@ private void handleDateTimeFormatPatterns(String[] patternKeys, Map<String, Obje
542
542
if (pattern != null ) {
543
543
// Perform date-time format pattern conversion which is
544
544
// applicable to both SimpleDateFormat and j.t.f.DateTimeFormatter.
545
- String transPattern = translateDateFormatLetters (calendarType , pattern , this ::convertDateTimePatternLetter );
545
+ String transPattern = translateDateFormatLetters (calendarType , key , pattern , this ::convertDateTimePatternLetter );
546
546
dateTimePatterns .add (i , transPattern );
547
547
// Additionally, perform SDF specific date-time format pattern conversion
548
- sdfPatterns .add (i , translateDateFormatLetters (calendarType , transPattern , this ::convertSDFLetter ));
548
+ sdfPatterns .add (i , translateDateFormatLetters (calendarType , key , transPattern , this ::convertSDFLetter ));
549
549
} else {
550
550
dateTimePatterns .add (i , null );
551
551
sdfPatterns .add (i , null );
@@ -568,7 +568,7 @@ private void handleDateTimeFormatPatterns(String[] patternKeys, Map<String, Obje
568
568
}
569
569
}
570
570
571
- private String translateDateFormatLetters (CalendarType calendarType , String cldrFormat , ConvertDateTimeLetters converter ) {
571
+ private String translateDateFormatLetters (CalendarType calendarType , String patternKey , String cldrFormat , ConvertDateTimeLetters converter ) {
572
572
String pattern = cldrFormat ;
573
573
int length = pattern .length ();
574
574
boolean inQuote = false ;
@@ -587,7 +587,7 @@ private String translateDateFormatLetters(CalendarType calendarType, String cldr
587
587
if (nextc == '\'' ) {
588
588
i ++;
589
589
if (count != 0 ) {
590
- converter .convert (calendarType , lastLetter , count , jrePattern );
590
+ converter .convert (calendarType , patternKey , lastLetter , count , jrePattern );
591
591
lastLetter = 0 ;
592
592
count = 0 ;
593
593
}
@@ -597,7 +597,7 @@ private String translateDateFormatLetters(CalendarType calendarType, String cldr
597
597
}
598
598
if (!inQuote ) {
599
599
if (count != 0 ) {
600
- converter .convert (calendarType , lastLetter , count , jrePattern );
600
+ converter .convert (calendarType , patternKey , lastLetter , count , jrePattern );
601
601
lastLetter = 0 ;
602
602
count = 0 ;
603
603
}
@@ -614,7 +614,7 @@ private String translateDateFormatLetters(CalendarType calendarType, String cldr
614
614
}
615
615
if (!(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' )) {
616
616
if (count != 0 ) {
617
- converter .convert (calendarType , lastLetter , count , jrePattern );
617
+ converter .convert (calendarType , patternKey , lastLetter , count , jrePattern );
618
618
lastLetter = 0 ;
619
619
count = 0 ;
620
620
}
@@ -627,7 +627,7 @@ private String translateDateFormatLetters(CalendarType calendarType, String cldr
627
627
count ++;
628
628
continue ;
629
629
}
630
- converter .convert (calendarType , lastLetter , count , jrePattern );
630
+ converter .convert (calendarType , patternKey , lastLetter , count , jrePattern );
631
631
lastLetter = c ;
632
632
count = 1 ;
633
633
}
@@ -637,7 +637,7 @@ private String translateDateFormatLetters(CalendarType calendarType, String cldr
637
637
}
638
638
639
639
if (count != 0 ) {
640
- converter .convert (calendarType , lastLetter , count , jrePattern );
640
+ converter .convert (calendarType , patternKey , lastLetter , count , jrePattern );
641
641
}
642
642
if (cldrFormat .contentEquals (jrePattern )) {
643
643
return cldrFormat ;
@@ -661,7 +661,7 @@ private String toMetaZoneKey(String tzKey) {
661
661
* on the support given by the SimpleDateFormat and the j.t.f.DateTimeFormatter
662
662
* for date-time formatting.
663
663
*/
664
- private void convertDateTimePatternLetter (CalendarType calendarType , char cldrLetter , int count , StringBuilder sb ) {
664
+ private void convertDateTimePatternLetter (CalendarType calendarType , String patternKey , char cldrLetter , int count , StringBuilder sb ) {
665
665
switch (cldrLetter ) {
666
666
case 'u' :
667
667
case 'U' :
@@ -683,7 +683,7 @@ private void convertDateTimePatternLetter(CalendarType calendarType, char cldrLe
683
683
* Perform a conversion of CLDR date-time format pattern letter which is
684
684
* specific to the SimpleDateFormat.
685
685
*/
686
- private void convertSDFLetter (CalendarType calendarType , char cldrLetter , int count , StringBuilder sb ) {
686
+ private void convertSDFLetter (CalendarType calendarType , String patternKey , char cldrLetter , int count , StringBuilder sb ) {
687
687
switch (cldrLetter ) {
688
688
case 'G' :
689
689
if (calendarType != CalendarType .GREGORIAN ) {
@@ -722,6 +722,17 @@ private void convertSDFLetter(CalendarType calendarType, char cldrLetter, int co
722
722
appendN ('z' , count , sb );
723
723
break ;
724
724
725
+ case 'y' :
726
+ // If the style is FULL/LONG for a Japanese Calendar, make the
727
+ // count == 4 for Gan-nen
728
+ if (calendarType == CalendarType .JAPANESE &&
729
+ (patternKey .contains ("full-" ) ||
730
+ patternKey .contains ("long-" ))) {
731
+ count = 4 ;
732
+ }
733
+ appendN (cldrLetter , count , sb );
734
+ break ;
735
+
725
736
case 'Z' :
726
737
if (count == 4 || count == 5 ) {
727
738
sb .append ("XXX" );
@@ -767,6 +778,7 @@ private void handleSkeletonPatterns(Map<String, Object> myMap, CalendarType cale
767
778
.collect (Collectors .toMap (
768
779
e -> calendarPrefix + e .getKey (),
769
780
e -> translateDateFormatLetters (calendarType ,
781
+ e .getKey (),
770
782
(String )e .getValue (),
771
783
this ::convertDateTimePatternLetter )
772
784
))
@@ -775,7 +787,7 @@ private void handleSkeletonPatterns(Map<String, Object> myMap, CalendarType cale
775
787
776
788
@ FunctionalInterface
777
789
private interface ConvertDateTimeLetters {
778
- void convert (CalendarType calendarType , char cldrLetter , int count , StringBuilder sb );
790
+ void convert (CalendarType calendarType , String patternKey , char cldrLetter , int count , StringBuilder sb );
779
791
}
780
792
781
793
/**
0 commit comments