Last active
August 30, 2015 14:19
-
-
Save toandv/5cb48f30a67ca72951eb to your computer and use it in GitHub Desktop.
DateTime format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) throws JsonProcessingException { | |
ObjectMapper objectMapper = new ObjectMapper(); | |
objectMapper.registerModule(new JavaTimeModule()); | |
System.out.println(objectMapper.writeValueAsString(new Entity())); | |
} | |
static class Entity { | |
ZonedDateTime time = ZonedDateTime.now(); | |
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ") | |
public ZonedDateTime getTime() { | |
return time; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment