Ticket #6341 (closed defect: fixed)

Bug contains 2 commit(s) | SVN Diffs for #6341

 

Opened 7 months ago

Last modified 3 months ago

DateTimePatternGenerator returns wrong result for narrow date format

Reported by: claireho Assigned to: claireho
Priority: major Milestone: 4.0
Component: formatting Version: 3.9.1
Keywords: Cc: mark
Load: Xref:
Java Version: Operating System:
Project (C/J): all Weeks:
Review: mark

Description

DateTimePatternGenerator returns wrong result for narrow date format.

Locale: any
Skeleton: yMMMMMd
Best Pattern: y ('Day':d)

Attachments

Change History

06/10/08 14:58:00 changed by claireho

  • cc set to mark.
  • owner changed from claireho to mark.

06/10/08 16:09:54 changed by claireho

The problem is in the DateTimeMatcher.set() which set the appearance for elements. If the element appears in the skeleton, it casts the subTypeValue from int to byte.

type[typeValue] = (byte) subTypeValue;

Because static value of NARROW is -0x100, the type[typeValue] is set to 0 after casting to byte. Therefore, skeleton "yMMMMMd" is same as "yd". I redefined the value for NARROW, SHORT and LONG but got one test failed. I think the new result looks better than original one. This is the failure:

Locale: en_US
Skeleton: yMMMd
Expecting result: Jan/13/1999
Got result: Jan 13, 1999

Comparing the distance before and after:

Pattern:M/d/y Distance before: 3 Distance after: 4
Pattern:MMMM d,yyyy Distance before: 4 Distance after: 4

Mark, please let me know if you have any concern. Thanks!

06/11/08 09:49:12 changed by claireho

07/15/08 14:48:58 changed by mark

  • owner changed from mark to claireho.

07/15/08 14:49:12 changed by mark

  • revw set to mark.

09/30/08 01:30:35 changed by mark

  • status changed from new to closed.
  • resolution set to fixed.

Add/Change #6341 (DateTimePatternGenerator returns wrong result for narrow date format)




Anti spam check: