IsoDate.stringToDate error

181 views
Skip to first unread message

CJGarber

unread,
Jan 17, 2012, 4:23:37 PM1/17/12
to ksoap2-android
IsoDate.stringToDate is generating an odd error when passed a date/
time string that includes milliseconds when the IsoDate.DATE_TIME flag
is used.

eg IsoDate.stringToDate("2012-01-17T19:30:26", IsoDate.DATE_TIME)
works fine, but
IsoDate.stringToDate("2012-01-17T19:30:26.003", IsoDate.DATE_TIME)
produces this error message:

"java.lang.StringIndexOutOfBoundsException: index=12 length=12"

If the IsoDate.DATE flag is used, there is no problem with either
string

Manfred Moser

unread,
Jan 17, 2012, 4:51:22 PM1/17/12
to ksoap2-...@googlegroups.com
I dont know why this class is there the first place. Afaik though your
string is invalid as an isodate string (see
http://en.wikipedia.org/wiki/ISO_8601) since you are missing the Z at
the end.

If you want to debug or so the code is here and could probably use a
unit test along these lines...

https://github.com/mosabua/kobjects/tree/0.0-SNAPSHOT-20040926-mvn2/kobjects-j2me/src/main/java/org/kobjects/isodate

manfred

CJGarber

unread,
Jan 17, 2012, 5:49:48 PM1/17/12
to ksoap2-android
I started to use that class after seeing an example for marshalling
dates at:
http://seesharpgears.blogspot.com/2010/11/implementing-ksoap-marshal-interface.html
Should I not be using it?

re: the date string format.....this is the date string generated by a
SOAP (.NET) Web Service.
Looking at the wiki link you posted, under the "Combined date and time
representations" section, both Z and no-Z formats are listed as
acceptable.

However, looking at the code you posted a link to, I can see where it
is probably going wrong.....the break condition in this loop
definitely expects a non-numeric char of some kind after the millis:
int ms = 0;
int f = 100;
while (true) {
char d = text.charAt(++pos);
if (d < '0' || d > '9') <<<<<<<<<<PROBLEM when no
'Z' at end of time string
break;
ms += (d - '0') * f;
f /= 10;
}

I have no experience with contributing to open source projects, and
don't have the time right now to learn how, so I'll leave the actual
code fix to someone else.
I don't care about the time portion of the date right now, so I'll
just use the DATE flag when calling the function...


On Jan 17, 1:51 pm, Manfred Moser <mosa...@gmail.com> wrote:
> I dont know why this class is there the first place. Afaik though your
> string is invalid as an isodate string (seehttp://en.wikipedia.org/wiki/ISO_8601) since you are missing the Z at
> the end.
>
> If you want to debug or so the code is here and could probably use a
> unit test along these lines...
>
> https://github.com/mosabua/kobjects/tree/0.0-SNAPSHOT-20040926-mvn2/k...

Manfred Moser

unread,
Jan 17, 2012, 5:51:45 PM1/17/12
to ksoap2-...@googlegroups.com

Could you create an issue that point to this thread as your contribution...

Manfred Moser

unread,
Jan 18, 2012, 12:14:29 AM1/18/12
to ksoap2-...@googlegroups.com
Thanks for filing the issue.
Reply all
Reply to author
Forward
0 new messages