0

I meet the problem with this code:

SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy");
Date date = df.parse("2013-03-07 23:59:00.0")

I get the exception:

java.text.ParseException: Unparseable date: java.text.ParseException: Unparseable date: "2013-03-07 23:59:00.0"

How can I convert this kind of String to Date?

Ry-
  • 209,133
  • 54
  • 439
  • 449
hoang nguyen
  • 1,959
  • 5
  • 20
  • 20

2 Answers2

2

Change it to

new SimpleDateFormat("yyyy-MM-dd HH:mm:ss'.0'");

Your date is not in the format MM/dd/yyyy, so why did you write that? (I have no idea what the .0 is at the end, so I just hardcoded that)

Documentation

tckmn
  • 55,458
  • 23
  • 108
  • 154
1

Try this

    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date date = df.parse("2013-03-07 23:59:00.0");
Jans
  • 10,901
  • 3
  • 35
  • 44