The Source for Java Technology Collaboration


JSR 310 Date and Time - Choices - Calendar class names

This choice is about how we should name the calendar classes.

The following class names are believed to be agreed:

  • Year
  • YearMonth
  • MonthDay
  • YearWeek


Option 1 - Obvious names (JDK clash)

  • Date
  • Time
  • DateTime

These names are a gamble, based on how rapidly JSR-310 replaces the older API. I believe that it won't be that rapid, and as such the confusion simply isn't worth it.


Option 2 - Minimal suffix

  • DateYMD
  • TimeHMS
  • DateTime

This works by adding the least possible to get a unique class name. It has the advantage that IDE auto complete for a date or time will rapidly find the relevant class (although DateYMD? is after DateTime? alphabetically). The downside is that it uses abbreviations, and some may assume that only the year-month-day fields are accessible, and not day of week/week of weekyear etc.

Variations on the suffix theme might include Date310/Time310 or DateJSR?/TimeJSR.


Option 3 - Calendar prefix

  • CalendarDate
  • CalendarTime
  • CalendarDateTime

A 'calendar date' makes sense, but a ''calendar time' or 'calendar date and time' doesn't really. A desk calendar has dates on it, not times.


Option 4 - Wall prefix

  • WallDate
  • WallTime
  • WallDateTime

A 'wall time' makes sense (the time shown on a wall clock), but a 'wall date' or 'wall date and time' is stretching a little (not as bad as 'calendar time' though, as you could have a calendar on the wall).


Option 5 - Calendar/Wall combination

  • CalendarDate
  • WallTime
  • DateTime

Each element makes sense and is well named individually. But it is unclear that there is a connection between the three classes. ie. that CalendarDate + WallTime -> DateTime.


Option 6 - NoZone prefix

  • NoZoneDate
  • NoZoneTime
  • NoZoneDateTime

The no zone prefix refers to the lack of timezone. Describing a class by what it doesn't have seems backwards however.


Option 7 - Local prefix

  • LocalDate
  • LocalTime
  • LocalDateTime

The local prefix refers to the date/time/date-time being independent of timezone and local to the observer. It meets the common prefix test for easy learning - LocalDate + LocalTime -> LocalDateTime. Local is also a short prefix (being short does help on readability. Finally, it will be familiar to Joda-Time upgraders.

Apparantly, RFC2445 (icalendar) uses the 'local' terminology for "A local-time event at 5pm occurs at 5pm no matter what time zone the participant is in" (via Neal Gafter).


Topic DateTimeCalendarClassNames . { Edit | Ref-By | Printable | Diffs r1 | More }
 XML java.net RSS

Revision r1 - 31 Oct 2007 - 22:48:59 - Main.scolebourne
Parents: WebHome > DateTimeAPI > DateTimeScope > DateTimeChoices