Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8354364

SimpleDateFormat introduces disambiguation for 12 am / 12 pm

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      21.0.1.12

      A DESCRIPTION OF THE PROBLEM :
      There is ambiguation between 12:00 am and 12:00pm in the 12 hour clock format.
      Whilst Java may define this (but not in https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/text/SimpleDateFormat.html), the date may be formatted for display to non programmers.
      Additionally the date format may use a server locale for formatting where a user may be used to the 24 hour clock.

      As there is no such thing as 12:00:00.0000 AM (or PM) by definition noon can not be either pre or post meridiem (https://www.rmg.co.uk/stories/topics/noon-12-am-or-12-pm) this can lead to confusion for end users.

      when formatting times that are either noon or midday (or would show as such because the seconds / minutes are dropped) AM/PM should be (optionally) replaced with a localaized noon/midnight.

      For backwards compatability this could be done by usign a new letter for SimpleDateFormat that uses AM/PM/Noon/Midnight as appropriate.

      Current workaround is to not use the core JDK feature and switch to ICU4j (https://unicode-org.github.io/icu/userguide/format_parse/datetime/#date-field-symbol-table using the `b` format)

            naoto Naoto Sato
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: