Created
September 12, 2012 19:20
-
-
Save collinvandyck/3709237 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) | |
| public class User { | |
| private static final DateFormat ISO_8601_FORMATTER = new ISO8601DateFormat(); | |
| public static String dateToISO8601Format(Date date) { | |
| if (date == null) { | |
| return null; | |
| } | |
| return ISO_8601_FORMATTER.format(date); | |
| } | |
| private String id; | |
| private String email; | |
| @JsonIgnore private Date createdAt; | |
| @JsonIgnore private Date updatedAt; | |
| private String name; | |
| private boolean admin; | |
| @JsonIgnore private boolean active; | |
| public User(String id, String email, Date createdAt, Date updatedAt, String name, boolean admin, boolean active) { | |
| this.id = id; | |
| this.email = email; | |
| this.createdAt = createdAt; | |
| this.updatedAt = updatedAt; | |
| this.name = name; | |
| this.admin = admin; | |
| this.active = active; | |
| } | |
| // getter methods elided for readability. | |
| @JsonProperty("created_at") | |
| public String getCreatedAtISO8601() { | |
| return dateToISO8601Format(getCreatedAt()); | |
| } | |
| @JsonProperty("updated_at") | |
| public String getUpdatedAtISO8601() { | |
| return dateToISO8601Format(getUpdatedAt()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment