Document apply(String input) { ObjectMapper objectMapper = new ObjectMapper(); Timestamp timestamp = objectMapper.readValue(input, Timestamp.class); Map<String, Object> value = objectMapper.convertValue(timestamp, new TypeReference<Map<String, Object>>() { }); Document document = new Document(value); return document; } }