Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fastJSON.deserializer.CreateDateTime(String value) throws exception when ms is not 3 digits #23

Closed
B9Tony opened this issue Apr 5, 2016 · 2 comments

Comments

@B9Tony
Copy link

B9Tony commented Apr 5, 2016

If a date contains a 2 digit or 1 digit number of milliseconds an exception is thrown by CreateInteger, called by CreateDate, it can be fixed by checking for 'Z' first then calculating the length of milliseconds:

            hour = CreateInteger(value, 11, 2);
            min = CreateInteger(value, 14, 2);
            sec = CreateInteger(value, 17, 2);

            if (value[value.Length - 1] == 'Z')
                utc = true;
            if (value.Length > 21 && value[19] == '.')
                ms = CreateInteger(value, 20, (value.Length - (utc ? 21:20)));

Data Example:

webServiceResults.txt

@RiPont
Copy link

RiPont commented May 19, 2017

This also applies to CreateDateTimeOffset.

@skottmckay
Copy link

#45 should handle DateTimeOffset better. Allows for 'Z' and the ISO8601 roundtrip format.

@mgholam mgholam closed this as completed Jun 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants