Re: RFR: JDK-8318761: MessageFormat pattern support for CompactNumberFormat, ListFormat, and DateTimeFormatter [v3]

2024-02-04 Thread Andrey Turbanov
On Fri, 2 Feb 2024 22:43:28 GMT, Justin Lu  wrote:

>> Please review this PR and [CSR](https://bugs.openjdk.org/browse/JDK-8319344) 
>> which adds MessageFormat pattern support for the following subformats: 
>> ListFormat, CompactNumberFormat, and DateTimeFormatter. This change is 
>> intended to provide pattern support for the more recently added JDK Format 
>> subclasses, as well as improving java.time formatting within i18n. The draft 
>> javadoc can be viewed here: 
>> https://cr.openjdk.org/~jlu/docs/api/java.base/java/text/MessageFormat.html. 
>> Please see the CSR for more in-depth behavioral changes, as well as 
>> limitations.
>> 
>> The `FormatTypes`:  dtf_date, dtf_time, dtf_datetime, pre-defined 
>> DateTimeFormatter(s), and list are added.
>> The `FormatStyles`: compact_short, compact_long, or, and unit are added.
>> 
>> For example, previously,
>> 
>> 
>> Object[] args = {LocalDate.of(2023, 11, 16), LocalDate.of(2023, 11, 27)};
>> MessageFormat.format("It was {0,date,full}, now it is {1,date,full}", args);
>> 
>> 
>> would throw `Exception java.lang.IllegalArgumentException: Cannot format 
>> given Object as a Date`
>> 
>> Now, a user can call
>> 
>> 
>> MessageFormat.format("It was {0,dtf_date,full}, now it is 
>> {1,dtf_date,full}", args);
>> 
>> 
>> which returns "It was Thursday, November 16, 2023, now it is Friday, 
>> November 17, 2023"
>
> Justin Lu has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Use Naoto's recommended example

src/java.base/share/classes/java/text/MessageFormat.java line 1771:

> 1769: String type = fType.name().charAt(0) + 
> fType.name().substring(1).toLowerCase(Locale.ROOT);
> 1770: try {
> 1771: return switch(fType) {

Suggestion:

return switch (fType) {

src/java.base/share/classes/java/text/MessageFormat.java line 1777:

> 1775: DateTimeFormatter.ofPattern(pattern).toFormat();
> 1776: case CHOICE -> new ChoiceFormat(pattern);
> 1777: default ->  throw new 
> IllegalArgumentException(String.format(

Suggestion:

default -> throw new IllegalArgumentException(String.format(

-

PR Review Comment: https://git.openjdk.org/jdk/pull/17663#discussion_r1477385804
PR Review Comment: https://git.openjdk.org/jdk/pull/17663#discussion_r1477386232


Re: RFR: JDK-8318761: MessageFormat pattern support for CompactNumberFormat, ListFormat, and DateTimeFormatter [v3]

2024-02-02 Thread Naoto Sato
On Fri, 2 Feb 2024 22:43:28 GMT, Justin Lu  wrote:

>> Please review this PR and [CSR](https://bugs.openjdk.org/browse/JDK-8319344) 
>> which adds MessageFormat pattern support for the following subformats: 
>> ListFormat, CompactNumberFormat, and DateTimeFormatter. This change is 
>> intended to provide pattern support for the more recently added JDK Format 
>> subclasses, as well as improving java.time formatting within i18n. The draft 
>> javadoc can be viewed here: 
>> https://cr.openjdk.org/~jlu/docs/api/java.base/java/text/MessageFormat.html. 
>> Please see the CSR for more in-depth behavioral changes, as well as 
>> limitations.
>> 
>> The `FormatTypes`:  dtf_date, dtf_time, dtf_datetime, pre-defined 
>> DateTimeFormatter(s), and list are added.
>> The `FormatStyles`: compact_short, compact_long, or, and unit are added.
>> 
>> For example, previously,
>> 
>> 
>> Object[] args = {LocalDate.of(2023, 11, 16), LocalDate.of(2023, 11, 27)};
>> MessageFormat.format("It was {0,date,full}, now it is {1,date,full}", args);
>> 
>> 
>> would throw `Exception java.lang.IllegalArgumentException: Cannot format 
>> given Object as a Date`
>> 
>> Now, a user can call
>> 
>> 
>> MessageFormat.format("It was {0,dtf_date,full}, now it is 
>> {1,dtf_date,full}", args);
>> 
>> 
>> which returns "It was Thursday, November 16, 2023, now it is Friday, 
>> November 17, 2023"
>
> Justin Lu has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Use Naoto's recommended example

LGTM

-

Marked as reviewed by naoto (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/17663#pullrequestreview-1860617335


Re: RFR: JDK-8318761: MessageFormat pattern support for CompactNumberFormat, ListFormat, and DateTimeFormatter [v3]

2024-02-02 Thread Justin Lu
> Please review this PR and [CSR](https://bugs.openjdk.org/browse/JDK-8319344) 
> which adds MessageFormat pattern support for the following subformats: 
> ListFormat, CompactNumberFormat, and DateTimeFormatter. This change is 
> intended to provide pattern support for the more recently added JDK Format 
> subclasses, as well as improving java.time formatting within i18n. The draft 
> javadoc can be viewed here: 
> https://cr.openjdk.org/~jlu/docs/api/java.base/java/text/MessageFormat.html. 
> Please see the CSR for more in-depth behavioral changes, as well as 
> limitations.
> 
> The `FormatTypes`:  dtf_date, dtf_time, dtf_datetime, pre-defined 
> DateTimeFormatter(s), and list are added.
> The `FormatStyles`: compact_short, compact_long, or, and unit are added.
> 
> For example, previously,
> 
> 
> Object[] args = {LocalDate.of(2023, 11, 16), LocalDate.of(2023, 11, 27)};
> MessageFormat.format("It was {0,date,full}, now it is {1,date,full}", args);
> 
> 
> would throw `Exception java.lang.IllegalArgumentException: Cannot format 
> given Object as a Date`
> 
> Now, a user can call
> 
> 
> MessageFormat.format("It was {0,dtf_date,full}, now it is {1,dtf_date,full}", 
> args);
> 
> 
> which returns "It was Thursday, November 16, 2023, now it is Friday, November 
> 17, 2023"

Justin Lu has updated the pull request incrementally with one additional commit 
since the last revision:

  Use Naoto's recommended example

-

Changes:
  - all: https://git.openjdk.org/jdk/pull/17663/files
  - new: https://git.openjdk.org/jdk/pull/17663/files/264799b0..bf0174ff

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk=17663=02
 - incr: https://webrevs.openjdk.org/?repo=jdk=17663=01-02

  Stats: 3 lines in 1 file changed: 0 ins; 2 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/17663.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/17663/head:pull/17663

PR: https://git.openjdk.org/jdk/pull/17663