Skip to content

Instantly share code, notes, and snippets.

@adammichalik
Last active September 2, 2016 07:13
Show Gist options
  • Save adammichalik/29e4d181409af312adab3a9f4ef6d6fe to your computer and use it in GitHub Desktop.
Save adammichalik/29e4d181409af312adab3a9f4ef6d6fe to your computer and use it in GitHub Desktop.
public class JodaTimeSerializationTest {
@Test
public void serializeDateTime() throws JsonProcessingException {
DateTime dateTime = DateTime.parse("2016-01-01T00:00:00Z");
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JodaModule());
objectMapper.configure(WRITE_DATES_AS_TIMESTAMPS , false);
System.out.println(objectMapper.writeValueAsString(dateTime)); // prints "2016-01-01T00:00:00.000Z"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment