javarosa
javarosa copied to clipboard
Migrate date and time code to the new Java8 Date/Time API
This issue depends on solving #286 and #290
Currently, our date and time code is based on java.util.Date which can unpredictable sometimes and generally difficult to work:
- It is mutable and doesn't have timezone/offset information.
- Testing with
Dateobjects is a pain because it's hard to get aDatefor a particular date andDateobjects are equal by reference, not by value. Also, timezones/offsets. - Its behavior depends on the
Calendarinstance that can be globally changed.
This is a good introduction to the new API: http://www.baeldung.com/java-8-date-time-intro
We should migrate every occurrence of Date in favor of LocalTime, LocalDate, LocalDateTime, OffsetDateTime, ZonedDateTime, Year, Month, and Duration.
The biggest issue to achieve this will probably be all the home-made date and time formatting code. That's why we will need to first create a test harness that checks any refactoring doesn't break current behavior.
Tracking:
- [ ] Test harness for date and time code
- [ ] Parsing strings into dates and times uses only Java8 API without home-made solutions
- [ ] Manipulation of dates and times uses only Java8 API without home-made solutions
- [ ] Formatting dates and times uses only Java8 API without home-made solutions