On Thu, 10 Aug 2023 16:59:14 GMT, Naoto Sato <na...@openjdk.org> wrote:
>> src/java.base/share/classes/java/text/ListFormat.java line 58: >> >>> 56: * .format(List.of("Foo", "Bar", "Baz")) >>> 57: * } >>> 58: * This will produce the concatenated list string, "Foo, Bar, and Baz" >>> as seen in >> >> With this sample code, if the Style is changed to SHORT, it would produce >> the same string. Would it be better to use the weekdays instead of Foo, Bar >> and Baz (as in the Unicode spec)? Esp. with the UNIT type, those examples >> explained it better, e.g. NARROW produces 3′ 7″. >> >> Also, if the instance is of STANDARD/SHORT, does it format >> List.of("January", "February", "March") and return "Jan., Feb., and Mar.", >> or 3 feet, 7 inches to 3 ft, 7 in? The format method states simply "Returns >> the string that consists of the input strings, concatenated with the >> patterns of this ListFormat." I wonder if it'd be helpful to explain a bit >> more or add one more sample. > > In fact, the sample in LDML's page seems to be incorrect. `standard-short` in > English is defined as: > > <listPattern type="standard-short"> > <listPatternPart type="start">{0}, {1}</listPatternPart> > <listPatternPart type="middle">{0}, > {1}</listPatternPart> > <listPatternPart type="end">{0}, & > {1}</listPatternPart> > <listPatternPart type="2">{0} & > {1}</listPatternPart> > </listPattern> > > in `en.xml` file. So `&` is expected rather than `and`. > >> Also, if the instance is of STANDARD/SHORT, does it format >> List.of("January", "February", "March") and return "Jan., Feb., and Mar.", >> or 3 feet, 7 inches to 3 ft, 7 in? > > No it does not. The `format()` method does not alter the passed input > strings, so it would not convert "January" to "Jan." even if `SHORT` Style is > specified. I have added some extra explanations, that those patterns vary > depending on the locale providers. Ah, I see. Those samples did give an impression that the format does more than concatenation. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15130#discussion_r1290711203