LocalTime反序列化错误

时间:2015-07-23 09:56:05

标签: java json spring web-services rest

在Spring中反序列化LocalTime时,我遇到了问题。

  

java.time.format.DateTimeParseException:Text'{“hour”:9,“minute”:0,“second”:0,“nano”:0}'无法在索引0处解析

这是我的代码:

@Override
public Office deserialize(JsonParser jsonParser,
        DeserializationContext deserializationContext) throws IOException,
        JsonProcessingException {


    ObjectCodec oc = jsonParser.getCodec();
    JsonNode node = oc.readTree(jsonParser);    

    office.setOpenFrom(LocalTime.parse(node.get("openFrom").toString()));

    return office;
}

我通过这种方法发送值:

@Test
public void readSingleBookmark() throws Exception {
    RestTemplate tmp = new RestTemplate();

    Office office = new Office();
    office.setOpenFrom(LocalTime.parse("09:00"));

    tmp.postForLocation("http://localhost:8080/register",office);
}

0 个答案:

没有答案