作为 this 的延续问题,错误似乎没有解决。 SQLite 中的日期存储为 2015-04-25
,其格式为 yyyy-MM-dd
。现在,该日期(即系统日期)使用 CURRENT_DATE 变量存储在数据库中并作为字符串获取。最小代码如下所示:
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date taskDate = dateFormat.parse(dateFormat.format(new Date("2015-04-25")));
但我得到一个异常(exception):
Parse error: 2015-04-25
最佳答案
尝试这个工作代码。
Format formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String formattedCode = formatter.format("supply your date-time here");
我认为您应该在提供输入时添加时间和日期,或者必须删除 HH:mm:ss
部分。
关于java - Android 中解析日期时出现解析错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29860586/