javarosa icon indicating copy to clipboard operation
javarosa copied to clipboard

Migrate date and time code to the new Java8 Date/Time API

Open ggalmazor opened this issue 8 years ago • 0 comments

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 a Date for a particular date and Date objects are equal by reference, not by value. Also, timezones/offsets.
  • Its behavior depends on the Calendar instance 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

ggalmazor avatar Apr 04 '18 15:04 ggalmazor