【发布时间】:2017-01-04 13:28:25
【问题描述】:
我正在尝试使用我的 DateTimeFormat 模式获取当前的 DateTime,但我遇到了异常...
//sets the current date
DateTime currentDate = new DateTime();
DateTimeFormatter dtf = DateTimeFormat.forPattern("dd/MM/YYYY HH:mm").withLocale(locale);
DateTime now = dtf.parseDateTime(currentDate.toString());
我遇到了这个异常,我不明白是谁给出了格式错误的格式
java.lang.IllegalArgumentException: Invalid format: "2017-01-04T14:24:17.674+01:00" is malformed at "17-01-04T14:24:17.674+01:00"
【问题讨论】:
-
您是尝试将日期格式化为字符串还是尝试将字符串解析为日期时间对象?
-
应该是一个DateTime对象
-
但是你开始是
DateTime- 为什么要把它转换成文本然后再转换回来?