| Issue 3731: | Parsing mistake in java.sql.Date.valueOf(String) | |
| 3 people starred this issue and may be notified of changes. | Back to list |
Sign in to add a comment
|
Found in GWT Release (e.g. 1.5.3, 1.6 RC):
GWT 1.6.4
Encountered on OS / Browser (e.g. WinXP, IE6-7, FF3):
Ubuntu 8.0.4 / every Browser
Detailed description (please be as specific as possible):
Inside the Date.valueOf-Method, the year, month and day is decoded into an
integer via "Integer.decode()". This effects that the months or days with a
leading zero are interpreted as an octal number and the validation after
decoding fails.
Shortest code snippet which demonstrates issue (please indicate where
actual result differs from expected result):
{{{
String value = "1970-01-08";
Date parsedDate = Date.valueOf(value); // <-- throw an
IllegalArgumentException which based on wrong usage of Integer.decode()
inside Date.valueOf()
}}}
Workaround if you have one:
Remove the leading zeros on month and day.
|
||||||||||||||||
,
Jun 08, 2009
Reproduced in WinXP / 1.6.4 / Chrome / FF3 / IE7. I wasn't able to reproduce this in hosted mode, but I did receive uncaught exceptions in web mode until I removed the leading 0s in the example date above.
Owner: sco...@google.com
Labels: Category-JRE Type-Defect |
|||||||||||||||||
,
Jun 09, 2009
(No comment was entered for this change.)
Owner: tamplinjohn
|
|||||||||||||||||
,
Jun 09, 2009
Sumit: hosted mode uses the real JRE not our emulation. Joel: copying you since I think this needs to go into 1.6 point release.
Status: Accepted
Cc: j...@google.com Labels: Milestone-NextRelease Priority-Critical |
|||||||||||||||||
,
Jun 23, 2009
I understand after viewing the emulation of java.sql.Date that the problem is that parsing days begining with '0' are interpreted as being in Octal (base 8) so a day of value 08 is invalid and javascript returns NaN which triggers the exception (case '2009-06-08'). I solved it in my app just trimming away the leading ceros before calling valueOf() but this has to be done inside Date.valueOf(). Hope this helps and that I am right in my guess. |
|||||||||||||||||
,
Jun 23, 2009
Committed to trunk at r5616 (TBR Joel).
Status: FixedNotReleased
Labels: ReviewBy-jgw |
|||||||||||||||||
,
Jun 23, 2009
@manuca: Thats exactly the problem. My workaround was the same as yours, removing the leading zeros before calling Date.valueOf(). |
|||||||||||||||||
,
Aug 07, 2009
This problem exists since 1.5.3 at least. |
|||||||||||||||||
,
Nov 15, 2009
(No comment was entered for this change.)
Labels: -Milestone-NextRelease Milestone-2_0_RC1
|
|||||||||||||||||
,
Nov 23, 2009
(No comment was entered for this change.)
Status: Fixed
|
|||||||||||||||||
|
|
|||||||||||||||||