Not able to understand “YYYY-MM-DDTHH:MM:SS” date format

前端 未结 3 569
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-12 03:47

I am trying to parse following date time string

2018-01-30T23:59:59.000

I am not able to understand which standard format it is like UTC or

3条回答
  •  醉酒成梦
    2020-12-12 04:18

    You need to escape the literal T:

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:SS");
    

    See This SO Answer for more examples

    Update: Your string is in the format

    yyyy-MM-dd'T'HH:mm:ss.SSS
    

    but you are trying to parse it with a completely uppercase format string.

    This does not do what you want it to do and you should read the documentation on SimpleDateFormat and the format string placeholders

提交回复
热议问题