我需要将字符串 531772200000
转换为 Java Date
对象。日期存储在数据库中。
当我这样做时,我收到java.text.ParseException: Unparseable date: "531772200000"
。
我的代码:
String dateToBeConverted = String.valueOf(dbObject.get("customerDateOfBirth"));
String parseabledate = dateToBeConverted
.replace("/Date(","")
.replace(")/","")
.replace("+0530", "");
dbObject.put("_id", String.valueOf(dbObject.get("userInfoId")));
SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy");
Date date;
date = formatter.parse(parseabledate);
最佳答案
这看起来像一个时间戳值,这可能会给你日期:
new Date(Long.parseLong("531772200000"));
计算时间为 1986 年 11 月 7 日星期五 18:30:00 GMT+0000
关于java.text.ParseException : Unparseable date: "531772200000",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27012901/