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

(cal) API: Need public API to calculate, format and parse "year of week"

    Details

    • Subcomponent:
    • Resolved In Build:
      b112
    • CPU:
      generic, x86, sparc
    • OS:
      generic, solaris_7, windows_2000
    • Verification:
      Verified

      Description

      Name: bb33257 Date: 08/31/99


      There is no way to have a date format string for a correct
      "year and week" date format as it is heavily used in Europe,
      especially in businesses. When you order something that takes
      more than a few days to deliver, then you will get something
      like "yyyy'-W'ww" as a delivery date, where "ww" is the week
      of the year and "yyyy" is the year according to the week
      calculation (and '-W' are two literal characters, the format
      looks like 1999-W31 for the 31st week of 1999).

      This year can be different from the year according to some of
      the days of that week.

      The ISO standard for dates specifies that the first week of the
      year is the one with the first Thursday of the week, and
      specifies Monday as the first day (in ICU locales, this is
      DateTimeElements { 2, 4 }). This is used all over Europe,
      although almost any other setting leads to the same issue.

      Taking the ISO/Europe standard as an example, the first day of
      this year, 1999-jan-01, a Friday, belongs to the last week of
      1998. In other words, 1998-W53 is from 1998-dec-28 (Monday) to
      1999-jan-03 (Sunday). Days of one year can belong to a week of
      the next or previous one.

      Our locales do not have a localPatternChar for it, nor does
      especially Calendar::EDateFields have a field constant for it.
      However, we do have code for the calculation:
      GregorianCalendar::getISOYear() . Unfortunately, this is (1) a
      private method that is not used anywhere, and (2) it is a
      misnomer, because this year value is not any more or less
      "ISO-y" than the day's year value. A better name would be
      along the line of "YearOfWeek" or so.

      In other words, it is right now not possible to have a
      DateFormat that produces a correct year-week date string
      as is used in many countries, but it would be fairly simple
      to add this to our code (and changing all localPatternChars
      to include a new character for this field).

      (Review ID: 94685)

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                okutsu Masayoshi Okutsu
                Reporter:
                bcbeck Brian Beck (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: