Search code examples
javastring-parsing

java.text.ParseException: Unparseable date: "531772200000"


I need to convert the string 531772200000 to a Java Date object. The date is stored in a database.

When I am doing this, I am getting java.text.ParseException: Unparseable date: "531772200000".

My code:

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);

Solution

  • This looks like a timestamp value, this will probably give you the date:

    new Date(Long.parseLong("531772200000"));
    

    which works out at Fri Nov 07 1986 18:30:00 GMT+0000