ParseException:无法解析的日期: [英] ParseException: Unparseable date:
问题描述
我有时间戳字符串,例如"2015-07-13T10:44:58Z",我尝试将其转换为日期对象,它始终会生成异常
I have timestamp string like "2015-07-13T10:44:58Z" whe I try convert this in date object it always generates the exception
Caused by: java.text.ParseException: Unparseable date: "2015-07-13T10:44:58Z"
我用于解析的代码就是这样
Code which I am using for parsing is like that
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
Date subscriptionDate = format.parse("2015-07-13T10:44:58Z");
我不知道我在做什么错.
I don't know what I am doing wrong.
推荐答案
patterm SSS
代表Millisecond
-这意味着您输入的内容必须在第二个小数点后3位-
The patterm SSS
stands for Millisecond
- which means that your input needs to have 3 decimal places after the second - see here.
但是,您的输入没有毫秒信息.您必须删除SSS
或手动添加数字(.000
).
Your input, however, has no millisecond information. You have to remove the SSS
or add the digits manually (.000
).
这篇关于ParseException:无法解析的日期:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!