-
Bug
-
Resolution: Fixed
-
P4
-
1.4.2, 6
-
b112
-
generic, x86, sparc
-
generic, solaris_7, windows_2000
-
Verified
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)
======================================================================
- duplicates
-
JDK-4746307 API: Date reports wrong week in the end of year 2002
- Closed
-
JDK-4985363 Changing Date to String and String to Date back couse loss of One Year
- Closed
-
JDK-4966499 SimpleDateFormat yyyy-ww changes year of Date parsed, formatted, reparsed
- Closed
- relates to
-
JDK-4103271 Calendar Week Nos. 0, 54 invalid
- Closed
-
JDK-4731296 (cal) API: WEEK_OF_YEAR numbering doesn't specify a unique date
- Closed
-
JDK-7064270 java/text/Format/DateFormat/WeekDateTest.java fails on OEL5.6 hi_IN.UTF-8
- Closed
-
JDK-4862638 SpinnerDateModel doesn't roll the year field when adding weeks in the editor
- Closed
-
JDK-7026810 SimpleDateFormat behaves strange
- Closed
-
JDK-4962427 (fmt) Provide support for 'U', 'V', 'G' and 'g' date/time conversions
- Open
-
JDK-4808661 [Fmt-Da] Add another formatting option to SimpleDateFormat for week-based year
- Closed
-
JDK-4977067 SimpleDateFormat should support DAY_OF_WEEK as digit as well
- Closed
-
JDK-6902861 (cal) GregorianCalendar roll WEEK_OF_YEAR is broken for January 1 2010
- Resolved
-
JDK-6218127 Ambiguous semantics of Celandar.YEAR in GregorianCalendar
- Closed