は、私は次のコードだ:JacksonとLocalDateTimeをシリアル化する方法は?
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
String now = new ObjectMapper().writeValueAsString(new SomeClass(LocalDateTime.now()));
System.out.println(now);
をそして、私はこれを取得:
{ "時間":{ "時間":20、 "分":49、 "第二": 42、 "ナノ":9900万、 "DAYOFYEAR":19、 "のdayOfWeek": "木曜日"、 "月": "1月"、 "DAYOFMONTH":19、 "年":2017、 "monthValue":1、 "年表":{" ID ":" ISO」、 "calendarType": "ISO8601"}}}
私は何を達成したいことはISO8601
内の文字列であります2017-01-19T18:36:51Z
この作業のようなものがありますか?DateFormat df = new SimpleDateFormat( "MM/dd/yy hh:mm a");次に: mapper.setDateFormat(df); – dave823