List of usage examples for com.fasterxml.jackson.databind.util StdDateFormat parse
public Date parse(String paramString)
From source file:org.jmingo.mapping.convert.mongo.type.deserialize.MongoDateDeserializer.java
/** * {@inheritDoc}/* w ww.jav a2 s.c om*/ */ @Override public Date deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonNode tree = jp.readValueAsTree(); if (tree.isPojo()) { POJONode pojoNode = (POJONode) tree; Object pojo = pojoNode.getPojo(); if (pojo instanceof Date) { return (Date) pojoNode.getPojo(); } else { throw new RuntimeException("unsupported date type, expected: " + Date.class.getName()); } } String stringDate = tree.asText(); StdDateFormat stdDateFormat = new StdDateFormat(); try { return stdDateFormat.parse(stringDate); } catch (ParseException e) { throw Throwables.propagate(e); } }