[threeten-dev] Issues for some methods in ChronoField and ChronoUnit

Patrick Zhang patrick.zhang at oracle.com
Fri May 10 00:01:22 PDT 2013


I guess we should make getName() and toString() return upper-case 
string. Then it looks ok.
Actually toString() in FormatStyle, ResolverStyle, SignStyle and 
TextStyle will return capital letters then they does not suffer the 
problem. :)

Regards
Patrick

On 5/10/13 1:23 PM, Patrick Zhang wrote:
> The similar issue happens to ChronoUnit also.
>
> Regards
> Patrick
>
> On 5/10/13 11:50 AM, Patrick Zhang wrote:
>> Hi Team,
>>
>> It looks the valueOf(String name), getName() and toString() are 
>> incompatible.
>> For example,
>> ===========
>>         System.out.println(ChronoField.SECOND_OF_DAY.getName());
>>         System.out.println(ChronoField.SECOND_OF_DAY.toString());
>> ===========
>> Both of them will print "SecondOfDay".
>>
>> But if you try below, it will throw exception:
>>         System.out.println(ChronoField.valueOf("SecondOfDay"));
>>
>> FYI, below code works well:
>>         System.out.println(ChronoField.valueOf("SECOND_OF_DAY"));
>>
>>
>> Personally I do not think it make sense. As one application engineer, 
>> I would believe below code should work:
>> =========
>> for(ChronoField field: ChronoField.values()){
>>                 assertEquals(ChronoField.valueOf(field.getName()), 
>> field);
>>         }
>> =========
>>
>> Regards
>> Patrick


More information about the threeten-dev mailing list