Reputation: 7577
I am trying to parse a date time string into a date object. However, I keep getting the wrong date but I dont know why. Can you help me?
My code looks like this:
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.mm.yy-HH:MM");
String test = serverEntry.getString("date") + "-" + serverEntry.getString("time");
String test2 = dateFormat.parse(test).toString();
An example run has these outputs:
test = "27.06.14-12:18" // as in 27th of June 2014, 12.18 (24-hours)
test2 = "Sat Jun 27 12:06:00 CEST 2015"
Upvotes: 0
Views: 65
Reputation: 5320
MM
specifies month of the year and mm
specifies minutes. So you need this instead:
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yy-HH:mm");
Reference: http://developer.android.com/reference/java/text/SimpleDateFormat.html
Upvotes: 3