-2
아래 테스트를 실행하면 "2016-11-11"이 출력됩니다. 여기서 무슨 일이 일어나고있는거야? 입력으로 제공 한 DateTime 문자열을 어떻게 인쇄 할 수 있습니까?Joda ISODateTimeFormat serialize/deserializing
import org.joda.time.DateTime;
import org.junit.Test;
public class Adapter2
extends XmlAdapter<String, DateTime>
{
public DateTime unmarshal(String value) {
return (org.joda.time.format.ISODateTimeFormat.dateTimeParser().parseDateTime(value));
}
public String marshal(DateTime value) {
return (org.joda.time.format.ISODateTimeFormat.dateTime().print(value));
}
@Test
public void test()
{
System.out.println(new Adapter3().marshal(new Adapter3().unmarshal("2016-11-12T00:00:00.000+08:00")));
}
}
테스트에는 Adapter3이 사용됩니다. 어댑터 2의 코드를 게시했습니다. –
@JBNizet 지적 해 주셔서 감사합니다. Adaptor2로 변경하면 동일한 결과가 도출됩니다. (이 문제를 해결하기 위해 원래 게시물을 편집 할 수 없습니다.) – vivid
정확히 어떤 문제입니까? 이 테스트를 실행하면 "2016-11-11"이 인쇄되지 않습니다. 그것은 내 시간대가 UTC보다 1 시간 앞선 유럽/파리 인 경우 예상 출력 인 2016-11-11T17 : 00 : 00.000 + 01 : 00을 인쇄합니다. 당신은 ** 실제로 ** 출력물을 가지고 있습니다. 대신에 무엇을 기대합니까? 그리고 왜 그럴까요? –