2013-04-18 2 views
-2

웹 서비스에서 datetime을 얻고 있습니다. 실제로 sqlserver db에서 데이터를 가져 오는 중입니다. 문자열을 Date로 변환하려고하면 구문 분석 예외가 발생합니다.구문 분석 중에 예외가 발생했습니다.

String tschedule = json.getString("ScheduledFor"); 
String tduration = json.getString("Duration"); 
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); 
SimpleDateFormat dateFormat1 = new SimpleDateFormat("HH:mm:ss"); 

Date schedule = new Date(); 
Date duration = new Date(); 

try 
{ 
schedule = dateFormat.parse(tschedule); //exception here, tschedule="2013-04-12T11:25:26.703" 
duration = dateFormat1.parse(tduration);//or exception here, tduration="03:10:00" 
} 
catch(Exception ex) 
{ 
Log.e("MEETINGS SERVICE", "Parse exception: " + ex.getMessage()); 
} 

UPDATE : 로그 캣의 ouptut : 04-18 18 : 54 : 48.690 : 여기

내 코드 E/회의 서비스 (8601) : DateParse 예외 : 파싱 할 날짜 : 2013-04- 12 : 11 : 25 : 26.703

+0

왜 하향 투표 – Daniel

+0

예외가 무엇입니까? 문자열이 맞습니까? 의견의 가치는 나를 위해 잘 작동합니다. –

답변

1

당신은 소수점 이하의 초를 놓치고 (굵은 부분) :

DateParse 예외 : 파싱 할 날짜 : 2013-04-12T11 : 25 : 26 0.703

당신이 변경 확인하여 패턴을 포함 시키려면 :

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); 
관련 문제