Bug in com.google.gwt.i18n.client.DateTimeFormat.parse() with empty String

25 views
Skip to first unread message

GreenGary

unread,
Jan 15, 2008, 8:16:03 AM1/15/08
to Google Web Toolkit
I probaly found a bug in the DateTimeFormat class. If you pass an
empty String (not a null) to the parse method, it throws an
java.lang.StringIndexOutOfBoundsException, but javadoc says

* Parses text to produce a {@link Date} value. An
* {@link IllegalArgumentException} is thrown if either the text is
empty or
* if the parse does not consume all characters of the text.

Here is the code snippet, where the exception is raised:

private int parseInt(String text, int[] pos) {
int ret = 0;
int ind = pos[0];
char ch = text.charAt(ind);

And here the stack trace:
java.lang.StringIndexOutOfBoundsException: String index out of range:
0
at java.lang.String.charAt(String.java:687)
at
com.google.gwt.i18n.client.DateTimeFormat.parseInt(DateTimeFormat.java:
1160)
at
com.google.gwt.i18n.client.DateTimeFormat.subParse(DateTimeFormat.java:
1426)
at
com.google.gwt.i18n.client.DateTimeFormat.parse(DateTimeFormat.java:
667)
at
com.google.gwt.i18n.client.DateTimeFormat.parse(DateTimeFormat.java:
598)

GreenGary

unread,
Jan 15, 2008, 8:25:14 AM1/15/08
to Google Web Toolkit
Format string is "HH:mm:ss",
Reply all
Reply to author
Forward
0 new messages