diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/ExampleGenerator.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/ExampleGenerator.java index 25c38c7ac04..29d975c1d7c 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/ExampleGenerator.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/ExampleGenerator.java @@ -2335,9 +2335,13 @@ private String handleDateFormatItem(String xpath, String value, boolean showCont // ldml/dates/calendars/calendar[@type="*"]/dateTimeFormats/dateTimeFormatLength[@type="*"]/dateTimeFormat[@type="atTime"]/pattern[@type="standard"] String formatType = parts.findAttributeValue("dateTimeFormat", "type"); // "standard" or "atTime" + String length = + parts.findAttributeValue( + "dateTimeFormatLength", "type"); // full, long, medium, short // For all types, show - // - date (of same length) with a single full time + // - date (of same length) with a single full time, or long time (abbreviated zone) if + // the date is short // - date (of same length) with a single short time // For the standard patterns, add // - date (of same length) with a short time range @@ -2369,19 +2373,22 @@ private String handleDateFormatItem(String xpath, String value, boolean showCont return ""; } String timeFormatXPathPrefix = timeFormatXPathForPrefix.substring(0, tfLengthOffset); - String timeFullFormatXPath = - timeFormatXPathPrefix.concat( - "timeFormatLength[@type=\"full\"]/timeFormat[@type=\"standard\"]/pattern[@type=\"standard\"]"); + String timeLongerFormatXPath = + (!length.equals("short")) + ? timeFormatXPathPrefix.concat( + "timeFormatLength[@type=\"full\"]/timeFormat[@type=\"standard\"]/pattern[@type=\"standard\"]") + : timeFormatXPathPrefix.concat( + "timeFormatLength[@type=\"long\"]/timeFormat[@type=\"standard\"]/pattern[@type=\"standard\"]"); String timeShortFormatXPath = timeFormatXPathPrefix.concat( "timeFormatLength[@type=\"short\"]/timeFormat[@type=\"standard\"]/pattern[@type=\"standard\"]"); - String timeFormatValue = cldrFile.getWinningValue(timeFullFormatXPath); - parts = XPathParts.getFrozenInstance(cldrFile.getFullXPath(timeFullFormatXPath)); + String timeFormatValue = cldrFile.getWinningValue(timeLongerFormatXPath); + parts = XPathParts.getFrozenInstance(cldrFile.getFullXPath(timeLongerFormatXPath)); String timeNumbersOverride = parts.findAttributeValue("pattern", "numbers"); - SimpleDateFormat tff = + SimpleDateFormat tlf = icuServiceBuilder.getDateFormat(calendar, timeFormatValue, timeNumbersOverride); - tff.setTimeZone(ZONE_SAMPLE); + tlf.setTimeZone(ZONE_SAMPLE); timeFormatValue = cldrFile.getWinningValue(timeShortFormatXPath); parts = XPathParts.getFrozenInstance(cldrFile.getFullXPath(timeShortFormatXPath)); @@ -2399,7 +2406,7 @@ private String handleDateFormatItem(String xpath, String value, boolean showCont List examples = new ArrayList<>(); String dfResult = df.format(DATE_SAMPLE); - String tffResult = tff.format(DATE_SAMPLE); + String tlfResult = tlf.format(DATE_SAMPLE); String tsfResult = tsf.format(DATE_SAMPLE); // DATE_SAMPLE is in the afternoon // Handle date plus a single full time. @@ -2414,7 +2421,7 @@ private String handleDateFormatItem(String xpath, String value, boolean showCont value, (Object[]) new String[] { - setBackground("'" + tffResult + "'"), + setBackground("'" + tlfResult + "'"), setBackground("'" + dfResult + "'") })); examples.add(dtf.format(DATE_SAMPLE)); diff --git a/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestExampleGenerator.java b/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestExampleGenerator.java index 697d5929904..8d18f9f18b4 100644 --- a/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestExampleGenerator.java +++ b/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestExampleGenerator.java @@ -802,7 +802,7 @@ public void TestDateTimeComboFormats() { "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/dateTimeFormats/dateTimeFormatLength[@type=\"long\"]/dateTimeFormat[@type=\"standard\"]/pattern[@type=\"standard\"]"); checkValue( "DateTimeCombo short std", - "〖❬9/5/99❭, ❬1:25:59 PM Eastern Standard Time❭〗〖❬9/5/99❭, ❬1:25 PM❭〗〖❬9/5/99❭, ❬7:00 AM – 1:25 PM❭〗〖❬today❭, ❬7:00 AM – 1:25 PM❭〗", + "〖❬9/5/99❭, ❬1:25:59 PM EST❭〗〖❬9/5/99❭, ❬1:25 PM❭〗〖❬9/5/99❭, ❬7:00 AM – 1:25 PM❭〗〖❬today❭, ❬7:00 AM – 1:25 PM❭〗", exampleGenerator, "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/dateTimeFormats/dateTimeFormatLength[@type=\"short\"]/dateTimeFormat[@type=\"standard\"]/pattern[@type=\"standard\"]"); checkValue(