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

version 1.2.70 com.alibaba.fastjson.JSONException: For input string: "2020-01-01 00:00:00 000" #3282

Closed
haedrig opened this issue Jun 19, 2020 · 2 comments

Comments

@haedrig
Copy link

haedrig commented Jun 19, 2020

version 1.2.70

 public class Test {
    public static void main(String[] args) {
        Demo demo = JSON.parseObject("{'date':'2020-01-01 00:00:00 000'}", Demo.class);
    }
}

class Demo {
    public Date date;
 }

Exception in thread "main" com.alibaba.fastjson.JSONException: For input string: "2020-01-01 00:00:00 000"
at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:693)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:396)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:300)
at com.alibaba.fastjson.JSON.parseObject(JSON.java:573)

@ZivYan
Copy link
Contributor

ZivYan commented Jun 19, 2020

auto recognize date format as below when deserialize:

  • ISO-8601 format
  • yyyy-MM-dd
  • yyyy-MM-dd HH:mm:ss
  • yyyy-MM-dd HH:mm:ss.SSS
  • miliseconds
  • miliseconds string
  • .NET JSON format
  • new Date(198293238)

for example
JSON.parseObject("{\"date\":\"2020-06-19 14:41:50.247\"}", Demo.class);

@p0mp0k0
Copy link

p0mp0k0 commented Jul 22, 2020

also do not support yyyy-MM-ddTHH:mm:ss, example '2020-06-19T14:41:50'

ZivYan added a commit to ZivYan/fastjson that referenced this issue Jul 24, 2020
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

3 participants