[threeten-dev] Issues for some methods in ChronoField
Patrick Zhang
patrick.zhang at oracle.com
Mon May 13 23:15:51 PDT 2013
On 5/14/13 1:57 PM, Patrick Zhang wrote:
> It looks it still fails. Is there any gap between us?
> I see ChronoField and ChronoUnit test fail in my latest execution.
> http://sqeweb.us.oracle.com/jsn/users/patrick/newresult3/report/html/index.html
>
>
> Detailed log:
> http://sqeweb.us.oracle.com/jsn/users/patrick/newresult3/work/java/time/tck/java/time/temporal/TCKChronoField.jtr
>
Sorry, a bit confusion.
The 2 test class have not been included in repo yet. It is new test file
that I want to add. :)
So here I attach the 2 two java file as your reference.
Only test_valueOf() will fail.
>
> I guess we may need to change something in
> src/share/classes/java/time/temporal/ChronoField.java and
> ChronoUnit.java.
> For example,
> "NANO_OF_SECOND("NanoOfSecond", NANOS, SECONDS, ValueRange.of(0,
> 999_999_999))," should be
> "NANO_OF_SECOND("NANO_OF_SECOND", NANOS, SECONDS, ValueRange.of(0,
> 999_999_999))?
>
> Regards
> Patrick
>
> On 5/13/13 3:16 PM, Stephen Colebourne wrote:
>> This code does work:
>>
>> for(ChronoField field: ChronoField.values()){
>> assertEquals(ChronoField.valueOf(field.name()), field);
>> }
>>
>> Note name(), not getName().
>>
>> Stephen
>>
>>
>> On 13 May 2013 02:41, Patrick Zhang<patrick.zhang at oracle.com> wrote:
>>> Hi Stephen,
>>>
>>> It is ok that getName() and toString() will return same thing.
>>> But the problem is below code does not work.
>>>
>>> =========
>>>
>>> for(ChronoField field: ChronoField.values()){
>>> assertEquals(ChronoField.valueOf(field.getName()),
>>> field);
>>> }
>>>
>>> =========
>>>
>>> I guess field.getName() should return something can be used by
>>> valueOf(String name).
>>>
>>> Regards
>>> Patrick
>>>
>>>
>>> On 5/10/13 6:19 PM, Stephen Colebourne wrote:
>>>> The enum constant name is available via name() as with all enums.
>>>>
>>>> getName() is a mixed case variant. By taking control of the
>>>> toString(), we ensure that all implementations (enum or non-enum) have
>>>> a consistent toString.
>>>>
>>>> Stephen
>>>>
>>>>
>>>> On 10 May 2013 04:50, Patrick Zhang<patrick.zhang at oracle.com> 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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: TCKChronoField.java
Url: http://mail.openjdk.java.net/pipermail/threeten-dev/attachments/20130514/e0066759/TCKChronoField-0001.java
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: TCKChronoUnit.java
Url: http://mail.openjdk.java.net/pipermail/threeten-dev/attachments/20130514/e0066759/TCKChronoUnit-0001.java
More information about the threeten-dev
mailing list