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-
  • 218,210
  • 55
  • 464
  • 476
hoang nguyen
  • 2,119
  • 5
  • 21
  • 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
  • 57,719
  • 27
  • 114
  • 156
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
  • 11,064
  • 3
  • 37
  • 45