The Source for Java Technology Collaboration


JSR 310 Date and Time - Choices - Calendar internal storage

This choice is about how to store data inside calendars.


Option 1 - year / month / day / hour / min / sec

This option would store data using the basic 6 fields. Unusual calendar systems would choose their own most important fields.

Advantages:

  • get/set to any of these specific fields is very quick
  • resolving invalid dates is obvious, as the leapyear/month/day combination is easy to check
  • add of small amounts within stored fields is easy

Disadvantages:

  • get/set to any other field is slow
  • difficult to represent an object like YearWeek (weekyear + week of year) as it doesn't fit
  • add requires complex calculation


Option 2 - duration from epoch in seconds

This option would store data using seconds.

Advantages:

  • get/set to all fields is calculated, those below day are quick
  • add is quick for all fields except month/year
  • able to represent any calendar, including ones like YearWeek (weekyear + week of year)
  • compareTo/equals/hashcode are quick
  • conversion to an instant is quick

Disadvantages:

  • get/set to all fields requires calculation
  • resolving invalid dates requires calculation of each of year/month/day
  • get/set day/month/year requires complex calculation
  • add month/year requires complex calculation


Option 3 - duration from epoch in seconds and months

This option would store data using the 2 durations - seconds and months. Unusual calendar systems would choose their own fields (the ones with discontinuities).

Advantages:

  • get/set to all fields is calculated, most calculations (esp. day/month/year) are quick
  • add is quick for all fields (unless an unusual field is not based on a standard field)
  • able to represent any calendar, including ones like YearWeek (weekyear + week of year), eg. by storing 1 duration in weeks
  • add month/year is quick

Disadvantages:

  • get/set to all fields requires calculation, but this is quick
  • resolving invalid dates requires calculation of each of year/month/day, but this is quick
  • add fields below month requires potentially complex calculation if they go over 28 days


Topic DateTimeCalendarInternalStorage . { Edit | Ref-By | Printable | Diffs r3 < r2 < r1 | More }
 XML java.net RSS

Revision r3 - 08 Oct 2007 - 21:20:07 - Main.scolebourne
Parents: WebHome > DateTimeAPI > DateTimeScope > DateTimeChoices