0

Im using the following code to convert from string with value 09:10:06 but in the cal set time I got exception: Unparseable date: "09:19:06" how can I overcome this issue.

DateFormat df = new SimpleDateFormat("dd.MM.yyyy");
Calendar cal  = Calendar.getInstance();
try {
cal.setTime(df.parse(memberValue));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Erik
  • 935
  • 11
  • 28
James Berners
  • 103
  • 2
  • 11
  • http://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html – Alexis C. Jun 16 '13 at 07:50
  • If your application is going to be working with dates heavily you might want to consider using JodaTime (http://joda-time.sourceforge.net/) – Jim Jun 16 '13 at 07:57

2 Answers2

1

The problem is you're trying to parse an hour with a wrong pattern. Here is the fix.

DateFormat df = new SimpleDateFormat("HH:mm:ss");
Tudor Zgureanu
  • 725
  • 7
  • 11
0

pattern should be dd:MM:yyyy for 09:10:06 input

jmj
  • 237,923
  • 42
  • 401
  • 438