-
Notifications
You must be signed in to change notification settings - Fork 13
Add mappers for java.time classes #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mappers for java.time classes #131
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Optimize imports
- It will be good to have integration tests for the mappers
if (value == null) { | ||
return null; | ||
} | ||
return Date.valueOf((LocalDate) value).getTime(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Date.valueOf((LocalDate) value).getTime(); | |
return ((LocalDate) value).toEpochDay(); |
return null; | ||
} | ||
long longValue = (Long) value; | ||
return new Date(longValue).toLocalDate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return new Date(longValue).toLocalDate(); | |
return LocalDate.ofEpochDay(longValue); |
if (value == null) { | ||
return null; | ||
} | ||
return Date.from(((LocalDateTime) value).toInstant(ZoneOffset.UTC)).getTime(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Date.from(((LocalDateTime) value).toInstant(ZoneOffset.UTC)).getTime(); | |
return ((LocalDateTime) value).toInstant(ZoneOffset.UTC).toEpochMilli(); |
- Added a unit test for LocalDateMapper and LocalDateTimeMapper - Changed LocalDateMapper to use EpochDays - Changed LocalDateTimeMapper to preserve full precision of the LocalDateTime down the nanosecond level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Consider implementing a
LocalTime
mapper - Code format
Added a mapper for LocalTime to round out Java 8 date / time classes. Included a unit test for them.
Added new mapper for Java's LocalDate and LocalDateTime as well as changing the TypeUtils