您好,我正在使用Joda time将字符串日期转换为DateTime对象。
我目前有以下字符串:
2014-02-16T00:17:20.000Z如何将其转换为DateTime对象?
我试过了:
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZZZ");
DateTime dt = formatter.parseDateTime("2014-02-16T00:17:20.000Z");但是我得到了以下错误:
java.lang.IllegalArgumentException: Invalid format: "2014-02-16T00:17:20.000Z" is malformed at ".000Z"非常感谢您的任何帮助。
发布于 2016-09-06 19:45:08
可能的问题是你们使用大写字母中的Z(区域
我已经测试了下面的代码,运行良好
SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz", Locale.ENGLISH);
Date date =formatter.parse("2016-09-06T08:35:02.530GMT");
DateTime d = new DateTime(date.getTime());https://stackoverflow.com/questions/21839143
复制相似问题