I have a string (ex: 2012-30-03 12:30), and I am trying to use the following code:
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
this.startTime = (Date) df.parse(startTime); // startTime = "2012-30-03 12:30"
But when I try the following:
System.out.println(this.startTime);
The following get printed
Tue Jun 03 12:30:00 CEST 2014
What the heck is wrong here?
Is there a better way to turn the kind of string I have into a working date object?
I think
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");should be
DateFormat df = new SimpleDateFormat("yyyy-dd-MM HH:mm");based on the example string you provided (
2012-30-03 12:30).Focus your rage against the date class into verifying the basics and you’ll be ok. 😉