android - ThreeTenABP: DateTimeParseException
问题描述
尝试更改字符串的日期格式但得到 DateTimeException:
String oldDate = "2018-12-18T17:04:56+00:00";
String outputFormat = "DD-MM";
try {
Instant instant = Instant.parse(oldDate);
LocalDateTime localDateTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
return localDateTime.format(DateTimeFormatter.ofPattern(outputFormat);
} catch (DateTimeException | IllegalArgumentException e) {
Log.e("Error", e.getLocalizedMessage());
return "";
}
我得到的错误是: 无法在索引 19 处解析文本“2018-12-18T17:04:56+00:00”
我正在使用 com.jakewharton.threetenabp:threetenabp:1.1.1 因为我不能使用 Java 8 类
解决方案
推荐阅读
- android - 如何在按钮的中心设置图像并使按钮在android中的约束布局中心
- python - Dask.distributed调度在不同主机上的工作人员之间
- lua - 插件消息的魔兽经典 API 事件?
- django - 在 Django 中,如何让 CreateView 只显示当前用户创建的对象?
- git-bash - ssh(突然)在 Windows Git Bash 中不可用
- javascript - 如何突出显示插入文本区域中的重复单词?
- python - 企业防火墙背后的网络流量
- arrays - 在聚合期间从数组中删除特定对象
- ios - 用户界面慢 IOS 开发
- c++ - 在 Linux 上编译没有问题时,如何在 Mac 上正确编译 C++?