문제

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();
}
도움이 되었습니까?

해결책

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");

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top