@@ -3104,10 +3104,10 @@ private void handleDateRangePattern(String value, List<String> examples) {
31043104 private void handleEras (XPathParts parts , String value , List <String > examples ) {
31053105 String calendarId = parts .getAttributeValue (3 , "type" );
31063106 String type = parts .getAttributeValue (-1 , "type" );
3107- String id =
3108- ( calendarId . startsWith ( "islamic " ))
3109- ? "islamic"
3110- : calendarId ; // islamic variations map to same sample
3107+ String id = calendarId ;
3108+ if ( id . equals ( "generic" ) || id . equals ( "iso8601 " )) {
3109+ id = "gregorian" ; // use Gregorian eras, 'generic' is not in the data
3110+ }
31113111 final SupplementalCalendarData .CalendarData calendarData =
31123112 supplementalDataInfo .getCalendarData ().get (id );
31133113
@@ -3123,21 +3123,48 @@ private void handleEras(XPathParts parts, String value, List<String> examples) {
31233123 GregorianCalendar startCal = forDateString (eraData .getStart ());
31243124 GregorianCalendar endCal = forDateString (eraData .getEnd ());
31253125
3126- if (startCal == null && endCal == null ) return ; // no data
3126+ final SupplementalCalendarData .EraData prevEra = calendarData .get (typeIndex - 1 );
3127+ final SupplementalCalendarData .EraData nextEra = calendarData .get (typeIndex + 1 );
3128+
3129+ if (startCal == null && prevEra != null && prevEra .getEnd () != null ) {
3130+ startCal = forDateString (prevEra .getEnd ());
3131+ // shift forward so we are in the next era
3132+ startCal .setTimeInMillis (startCal .getTimeInMillis () + (DateConstants .MILLIS_PER_DAY ));
3133+ }
3134+ if (endCal == null && nextEra != null && nextEra .getStart () != null ) {
3135+ endCal = forDateString (nextEra .getStart ());
3136+ // shift backward so we are in the prev era
3137+ endCal .setTimeInMillis (endCal .getTimeInMillis () - (DateConstants .MILLIS_PER_DAY ));
3138+ }
3139+
3140+ GregorianCalendar sampleDate = null ;
31273141
31283142 if (startCal != null && endCal != null ) {
3129- // go 2 days before end
3130- endCal .roll (Calendar .JULIAN_DAY , -2 );
3131- if (endCal .before (startCal )) {
3132- endCal = startCal ;
3143+ // roll back a day to not hit the edge
3144+ sampleDate = endCal ;
3145+ sampleDate .setTimeInMillis (
3146+ sampleDate .getTimeInMillis () - (DateConstants .MILLIS_PER_DAY ));
3147+ } else if (startCal == null && endCal != null ) {
3148+ // roll back a day to not hit the edge
3149+ sampleDate = endCal ;
3150+ sampleDate .setTimeInMillis (
3151+ sampleDate .getTimeInMillis () - (DateConstants .MILLIS_PER_DAY ));
3152+ } else if (startCal != null && endCal == null ) {
3153+ sampleDate = forDateString ("2002-07-15" ); // CLDR repo root commit
3154+ if (sampleDate .before (startCal )) {
3155+ sampleDate = startCal ;
3156+ sampleDate .setTimeInMillis (
3157+ sampleDate .getTimeInMillis () + (DateConstants .MILLIS_PER_DAY ));
31333158 }
3134- } else if ( startCal == null ) {
3135- endCal . roll ( Calendar . JULIAN_DAY , - 2 );
3136- } else if ( endCal == null ) {
3137- endCal = forDateString ( "2002-07-15" ); // CLDR repo root commit
3159+ } else {
3160+ // System.err.println("No good date for " + eraData );
3161+ // TODO: should be an error in TestSupplementalDataInfo
3162+ sampleDate = null ;
31383163 }
31393164
3140- final Date sample = endCal .getTime ();
3165+ if (sampleDate == null ) return ; // could not find the time
3166+
3167+ final Date sample = sampleDate .getTime ();
31413168
31423169 String skeleton = "Gy" ;
31433170 String checkPath =
0 commit comments