2012-05-13 4 views
0

내가 ISO 타임 스탬프 형식의 문자열로 변환하려고 SimpleDateFormat의 위해 ISO 타임 스탬프 형식으로 자바 문자열로 변환 :그래서 같은 <code>SimpleDateFormat</code>에

java.text.ParseException: Unparseable date: 
+0

'timestamp' 문자열의 값은 무엇입니까? –

+0

'timestamp'는 무엇을 출력합니까? –

답변

1
:

public static void convertDate() { 
    String timestamp = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(new Date()); 
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZZ"); 
    Date date = (Date)formatter.parse(timestamp); 
} 

위의 코드는 다음과 같은 예외가 발생합니다

XML의 날짜를 ISO 8601 형식으로 파싱하는 경우 JAXB 파서를 사용할 수 있습니다.

Check this post for an example

관련 문제