<i18n dev> Additional Date-Time Formats

Joe Wang huizhe.wang at oracle.com
Tue Jan 25 23:49:11 UTC 2022


Hi Naoto,

Looks good to me, and thanks for the explanation. I agree, AIOOBE would 
be a separate bug with ofPattern.

Thanks,
Joe

On 1/25/22 2:30 PM, Naoto Sato wrote:
> Hi Joe,
>
> On 1/24/22 5:50 PM, Joe Wang wrote:
>>         The 2nd and 3rd statements defined the requestedTemplate, 
>> does it imply the characters listed in the snippet are the only ones 
>> that are valid, in other words, can other characters under the 
>> Patterns section be used? It may be helpful to elaborate on the 
>> snippet a bit more.
>
> Those symbols represent each field, so other symbols are considered 
> illegal as a template symbol. Added some explanation there.
>
>>         Also, the range implies a valid range for a particular 
>> symbol, if that's the case, y and w feel like they are unbound. If I 
>> do that with ofPettern, I get ArrayIndexOutOfBoundsException.
>
> The spec of 'year' and 'number' presentations do not have any upper 
> limit number of letters, thus I added the '*' quantifier. Not exactly 
> sure why AIOOBE is thrown with ofPattern(), could be a separate bug? 
> It should be zero-padded or sign-padded.
>
>>
>> For the sample code, it might be helpful to put them in a code 
>> snippet and with the actual java code. If "yMMM" formats to 'Jun 
>> 2020', that might require some explanation too since that would be 
>> the same as ofPattern("MMM y") for the default(US) locale, or was it 
>> a typo?. (I'm not familiar with the use of DTF, just printed out 
>> date.format(DTF.ofPattern("yMMM" and "MMM y") :-))
>
> Well, it is not a typo and `ofLocalizedPattern("yMMM", Locale.US)` and 
> `ofPattern("MMM y", Locale.US)` both generating the same result is 
> exactly what this API is aiming at. Users don't need to pay attention 
> to locale specific format pattern with this API.
>
> HTH,
> Naoto



More information about the i18n-dev mailing list