Support date-only and time-only temporal types

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: Model
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Scope

      Support the temporal types that denote a date, or a time of day, rather than a point on the timeline:* java.time.LocalDate

      • java.time.LocalTime
      • java.time.LocalDateTime
      • java.time.OffsetTime
      • java.sql.Date
      • java.sql.Time
      • @Temporal(DATE) and @Temporal(TIME) on java.util.Date

      All of these are rejected at boot today.

      The design question

      MongoDB has no date-only and no time-only type. BSON Date is signed 64-bit milliseconds since the Unix epoch, in UTC, with no zone. So each type in scope needs an encoding decision, and the decision is a trade-off rather than a detail.

      Encoding them as BSON Date, at midnight UTC for a date and on the epoch day for a time of day, keeps them comparable, sortable and indexable, and keeps them usable by the datetime operators in HIBERNATE-88, which accept only a Date operand. The cost is documents that read as datetimes to anything outside Hibernate, with a midnight or a 1970 date that carries no meaning.

      The alternative encodings look more faithful in a document and forfeit all of that: an ISO-8601 string, an integer day number, or an integer nanosecond-of-day. String encodings of ISO-8601 dates do sort correctly, but they cannot be fed to any datetime operator without conversion, and a mixed encoding across temporal types would mean the translator can no longer treat temporal columns uniformly.

      OffsetTime carries an offset in addition to a time of day, so it also needs a time zone storage decision, in the way OffsetDateTime does.

            Assignee:
            Unassigned
            Reporter:
            Jeffrey Yemin
            None
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: