-
Enhancement
-
Resolution: Won't Fix
-
P5
-
None
-
6
-
None
-
other
-
solaris_10
Tested on jdk Java(TM) SE Runtime Environment (build 1.6.0-rc-b90)
sun blades 2500, solaris 10
JapaneseImperialCalendar sets wrong default date on era Taisho, Showa, and Heisei, except
Meiji. It sets the right year, but the wrong day. Currently it sets the day on
January 1, which is not the case for era Taisho, Showa, and Heisei according to
the calendar property. Because of this, if a user sets an era for Taisho, Showa, and Heisei without setting the date, the era will be changed quietly. Please see the attached simple code, which will illustrate the problem.
Some thoughts to find reasonable default dates based on the given fields and their associated normalization rules.
Here is the Japanese Calendar Properties:
# Meiji since 1868-01-01 00:00:00 local time (Gregorian)
# Taisho since 1912-07-30 00:00:00 local time (Gregorian)
# Showa since 1926-12-26 00:00:00 local time (Gregorian)
# Heisei since 1989-01-08 00:00:00 local time (Gregorian)
All the discussion below are limited to ERA are set to one of the above. And the discussion are limited to the following possible cases:
Day Mont Year Era
=================================
0 0 0 1 (case 1)
0 0 1 1 (case 2)
0 1 0 1 (case 3)
0 1 1 1 (case 5)
1 0 0 1 (case 4)
1 0 1 1 (case 6)
1 1 0 1 (case 7)
1 1 1 1 (case 8)
All the discussion leaves out the extreme cases for now.
=======================================
case 1: if ERA = given era
=======================================
suggest to set the default date to the starting date of the era.
e.g. if era = showa
current jdk suggest
--------------------------------------------
era > t era = s
year = 1 year = 1
month = 1 month = 12
day_of_mont = 1 day_of_mont = 26
============================================
case 2: if ERA = given era, YEAR = give year
============================================
a) if given year = 1, see case 1.
b) if given year < 1 || given year within the duration of the era || given year > duration, then
option1: stay the same implementation defined by the current jdk, set month = january, day_of_month = 1 and era will be normalized to the era based on the date as january, 1, starting year of the era + giving year - 1
if era = showa, year = 2
day_of_month = 1
month = january
year = 2 (given year)
era = s (given era)
option2: same as option1
option3: keep the given era, set year = given year, set month = starting month, day__of_month = starting day of the era
day_of_month = 26
month = december
year = 2 (given year)
era = s (given era)
other options: there are many other options. Open for discussion...
===============================================
case 3: if ERA = given era, MONTH = given month
===============================================
a) if given month = starting month of the given era,
suggest to keep the given era and month, set the year to 1 and set the day_of_month to the starting day of the era.
e.g. if era = showa, month = december
current jdk suggest
--------------------------------------------------------
era -> t era = s (given era)
year = 15 year = 1
era = december era = december (given year)
day_of_month = 1 day = 26
b) other scenarios, (no preference for the following options)
option1: stay the same implementation defined by the current jdk, set day_month = 1, set year = 1, stay the given month, then normalize the era and year field if necessary.
e.g. if era = showa, month = november
day_of_month = 1
month = november (given month)
date = november 1, 1926
era -> t
year -> 15
options2: keep the given fields as much as possible, set day = 1, keep the given month, set the default year to the next available year of the era if possible, if not, set next available era if possible, if not set to previous era if possible.
e.g. if era = showa, month = november
day_of_month = 1
month = november (given month)
era = s (given era)
year -> 2
date = november 1, 1927
option3: set day_of_month = starting day, add given month to starting month of the era then mod by 12
day_of_month = 26
month -> november
year-> 2
era = s (giving era)
other options: there are many other options. Open for discussion.
===========================================
case 4: if ERA = given era, DAY = given day
===========================================
a) if given day between the starting day of the era and the end day of the starting month of the era,
suggest to keep the given era and day_of_month, set year = 1, month = starting month of the era
e.g. if era = showa, day_of_month = 26..31
current jdk suggest
-----------------------------------------------------------------------
era -> t era = s (given era)
year -> 15 year = 1
month = january month = december
day_of_month = 26..31(given day) day_of_month = 26..31 (given day)
b) other scenarios (no preference for the following options)
option1: stay the same implementation defined by current jdk, set the default month to january.
e.g. if era = showa, day_of_month = 25
month = january
day_of_month = 25 (given day_of_month)
era -> t
year -> 15
option2: keep the given fields as much as possible, set the default month to january and set the next available year of the era if possible, if not, set next available era if possible, if not, move to the previous era if possible.
e.g. if era = showa, day_of_month = 25
era = s (given era)
month = january
day_of_month = 25 (given day_of_month)
year -> 2
option3: given day + starting day then mod number of days of the starting month.
e.g. if era = showa, day_of_month = 25
era = s (given era)
day_of_month-> 20
month -> january
year -> 2
other options: there are many other options. Open for discussion.
==================================================================
case 5: if ERA = given era, YEAR = given year, MONTH = given month
==================================================================
a) if given year = 1 and given month = the starting month of the era
e.g. if era = showa, year = 1, month = december
current jdk suggest
------------------------------------------------------------------------------
month = december(given month) month = december (given month)
day_of_month = 1 day_of_month = 26
era > t era = s (given era)
year -> 15 year = 1 (given year)
b) others scenarios(no preference for the following options),
option1: stay the same implementation defined by current jdk, set the day_of_month to 1
e.g. if era = s, year = 1, month = november
day_of_month = 1
month = november (given month)
era -> t
year -> 15
option2: keep the given fields as much as possible, set the default day to 1, set the next available month if possible, if not, set next available year if possible, set next available era if possible, if not, move to the previous era if possible.
e.g. if era = s, year = 1, month = november
day_of_month = 1
month -> january
year -> 2
era = s (given era)
or simply set the default day to 1, month to january, set the next available year of the era if possible, set next available era if possible, if not move to previous era
day_of_month = 1
month = january
year ->2
era = s (given era)
option3: set day_of_month = starting day, set the next available month by adding the given month + starting month then mod by 12...
day_of_month = starting day of the era
month -> november
year -> 2
era = 2 (given era)
other options: there are many other options. Open for discussion.
==============================================================
case 6: if ERA = given era, YEAR = given year, DAY = given day
==============================================================
a) if given year = 1 and given day = starting day .. end day of the starting month
e.g. if era = showa, year = 1, day_of_month = 30
current jdk suggest
-----------------------------------------------------------------------
era > t era = s (given era)
year -> 15 year = 1 (given year)
day_of_month = 30 day_of_month = 30 (given day)
month = january month = december
b) others scenarios: (no preference for the following options)
option1: stay the same implementation defined by current jdk, set the default month = january.
e.g. if era = showa, year = 1, day_of_month = 25
day_of_month = 25 (given year)
month = january
era -> t
year -> 15
option2: keep the given fields as much as possible, set the default month to january, set the next available year in the same era if possible, if not, set next available era if possible, move to the previous era if possible.
e.g. if era = showa, year = 1, day_of_month = 25
day_of_month = 25 (given day)
month = january
year -> 2
era = s (given era)
option3: adding the day to the starting day then mod by number of day of starting month ..
day_of_month -> 20
month -> january
year -> 2
era = s
other options: there are many other options. Open for discussion.
================================================================
case 7: if ERA = given era, MONTH = given month, DAY = given day
================================================================
a) if given month = starting month of the era and given day is between starting day and the end of day of the starting month, stay the same implementation defined by current jdk, set the year to 1
b) others scenarios: (no preference for the following options)
option1: stay the same implementation defined by current jdk, which set year = 1 and normalize the era.
e.g. if era = showa, month = november, day_of_month = 20
day_month = 20
month = november (given month)
year -> 15
era -> t
option2: keep the given fields as much as possible, normalize the year first if necessary to stay in the given era, if not, normalize the era
e.g. if era = showa, month = november, day_of_month = 20
day_of_month = 20 (given day_of_month)
month = november (given month)
year -> 2
era = s (given era)
option3: stay the given day, using given month to find the year by adding given month to starting month then mod by 12. There are many ways to do this approach, but no matter what kind of approach is selected, needs to consistently apply to the other scenarios as much as possible.
e.g. if era = showa, month = november, day = 20
day_of_month = 20
month -> november
year -> 2
era = s (given era)
===================================================================================
case 8: if ERA = given era, YEAR = given year, MONTH = given month, DAY = given day
===================================================================================
a) if no conflict of the given date, nothing need to be done
b) if need to normalize the date, the common option is to normalize the era like current implementation of the jdk.
other options: there are many other options. Open for discussion.
Summary:
Personally, I think we should consider the first year as a special case . There are lots of other options open for many scenarios in each case. As long as it is clearly documented and the implementation is consistent, I personally have no preference one way or the other, as they all have pros and cons.
I close this rfe for now. There are couple of reasons.
The first reason is the huge work load it represents, they are 256 (2 to power of 8) ossible cases for me to consider about, the fields are limited to YEAR, MONTH, WEEK_OF_YEAR, WEEK_OF_MONTH, DAY_OF_MONTH (DATE), DAY_OF_YEAR, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH where ERA = 1. That is why I limited our discussion to demonstrate my suggestion here.
Secondly, so far we have not seen any complains or request from other customers. From business point of view, we probably should concentrate on our customer requests first.
sun blades 2500, solaris 10
JapaneseImperialCalendar sets wrong default date on era Taisho, Showa, and Heisei, except
Meiji. It sets the right year, but the wrong day. Currently it sets the day on
January 1, which is not the case for era Taisho, Showa, and Heisei according to
the calendar property. Because of this, if a user sets an era for Taisho, Showa, and Heisei without setting the date, the era will be changed quietly. Please see the attached simple code, which will illustrate the problem.
Some thoughts to find reasonable default dates based on the given fields and their associated normalization rules.
Here is the Japanese Calendar Properties:
# Meiji since 1868-01-01 00:00:00 local time (Gregorian)
# Taisho since 1912-07-30 00:00:00 local time (Gregorian)
# Showa since 1926-12-26 00:00:00 local time (Gregorian)
# Heisei since 1989-01-08 00:00:00 local time (Gregorian)
All the discussion below are limited to ERA are set to one of the above. And the discussion are limited to the following possible cases:
Day Mont Year Era
=================================
0 0 0 1 (case 1)
0 0 1 1 (case 2)
0 1 0 1 (case 3)
0 1 1 1 (case 5)
1 0 0 1 (case 4)
1 0 1 1 (case 6)
1 1 0 1 (case 7)
1 1 1 1 (case 8)
All the discussion leaves out the extreme cases for now.
=======================================
case 1: if ERA = given era
=======================================
suggest to set the default date to the starting date of the era.
e.g. if era = showa
current jdk suggest
--------------------------------------------
era > t era = s
year = 1 year = 1
month = 1 month = 12
day_of_mont = 1 day_of_mont = 26
============================================
case 2: if ERA = given era, YEAR = give year
============================================
a) if given year = 1, see case 1.
b) if given year < 1 || given year within the duration of the era || given year > duration, then
option1: stay the same implementation defined by the current jdk, set month = january, day_of_month = 1 and era will be normalized to the era based on the date as january, 1, starting year of the era + giving year - 1
if era = showa, year = 2
day_of_month = 1
month = january
year = 2 (given year)
era = s (given era)
option2: same as option1
option3: keep the given era, set year = given year, set month = starting month, day__of_month = starting day of the era
day_of_month = 26
month = december
year = 2 (given year)
era = s (given era)
other options: there are many other options. Open for discussion...
===============================================
case 3: if ERA = given era, MONTH = given month
===============================================
a) if given month = starting month of the given era,
suggest to keep the given era and month, set the year to 1 and set the day_of_month to the starting day of the era.
e.g. if era = showa, month = december
current jdk suggest
--------------------------------------------------------
era -> t era = s (given era)
year = 15 year = 1
era = december era = december (given year)
day_of_month = 1 day = 26
b) other scenarios, (no preference for the following options)
option1: stay the same implementation defined by the current jdk, set day_month = 1, set year = 1, stay the given month, then normalize the era and year field if necessary.
e.g. if era = showa, month = november
day_of_month = 1
month = november (given month)
date = november 1, 1926
era -> t
year -> 15
options2: keep the given fields as much as possible, set day = 1, keep the given month, set the default year to the next available year of the era if possible, if not, set next available era if possible, if not set to previous era if possible.
e.g. if era = showa, month = november
day_of_month = 1
month = november (given month)
era = s (given era)
year -> 2
date = november 1, 1927
option3: set day_of_month = starting day, add given month to starting month of the era then mod by 12
day_of_month = 26
month -> november
year-> 2
era = s (giving era)
other options: there are many other options. Open for discussion.
===========================================
case 4: if ERA = given era, DAY = given day
===========================================
a) if given day between the starting day of the era and the end day of the starting month of the era,
suggest to keep the given era and day_of_month, set year = 1, month = starting month of the era
e.g. if era = showa, day_of_month = 26..31
current jdk suggest
-----------------------------------------------------------------------
era -> t era = s (given era)
year -> 15 year = 1
month = january month = december
day_of_month = 26..31(given day) day_of_month = 26..31 (given day)
b) other scenarios (no preference for the following options)
option1: stay the same implementation defined by current jdk, set the default month to january.
e.g. if era = showa, day_of_month = 25
month = january
day_of_month = 25 (given day_of_month)
era -> t
year -> 15
option2: keep the given fields as much as possible, set the default month to january and set the next available year of the era if possible, if not, set next available era if possible, if not, move to the previous era if possible.
e.g. if era = showa, day_of_month = 25
era = s (given era)
month = january
day_of_month = 25 (given day_of_month)
year -> 2
option3: given day + starting day then mod number of days of the starting month.
e.g. if era = showa, day_of_month = 25
era = s (given era)
day_of_month-> 20
month -> january
year -> 2
other options: there are many other options. Open for discussion.
==================================================================
case 5: if ERA = given era, YEAR = given year, MONTH = given month
==================================================================
a) if given year = 1 and given month = the starting month of the era
e.g. if era = showa, year = 1, month = december
current jdk suggest
------------------------------------------------------------------------------
month = december(given month) month = december (given month)
day_of_month = 1 day_of_month = 26
era > t era = s (given era)
year -> 15 year = 1 (given year)
b) others scenarios(no preference for the following options),
option1: stay the same implementation defined by current jdk, set the day_of_month to 1
e.g. if era = s, year = 1, month = november
day_of_month = 1
month = november (given month)
era -> t
year -> 15
option2: keep the given fields as much as possible, set the default day to 1, set the next available month if possible, if not, set next available year if possible, set next available era if possible, if not, move to the previous era if possible.
e.g. if era = s, year = 1, month = november
day_of_month = 1
month -> january
year -> 2
era = s (given era)
or simply set the default day to 1, month to january, set the next available year of the era if possible, set next available era if possible, if not move to previous era
day_of_month = 1
month = january
year ->2
era = s (given era)
option3: set day_of_month = starting day, set the next available month by adding the given month + starting month then mod by 12...
day_of_month = starting day of the era
month -> november
year -> 2
era = 2 (given era)
other options: there are many other options. Open for discussion.
==============================================================
case 6: if ERA = given era, YEAR = given year, DAY = given day
==============================================================
a) if given year = 1 and given day = starting day .. end day of the starting month
e.g. if era = showa, year = 1, day_of_month = 30
current jdk suggest
-----------------------------------------------------------------------
era > t era = s (given era)
year -> 15 year = 1 (given year)
day_of_month = 30 day_of_month = 30 (given day)
month = january month = december
b) others scenarios: (no preference for the following options)
option1: stay the same implementation defined by current jdk, set the default month = january.
e.g. if era = showa, year = 1, day_of_month = 25
day_of_month = 25 (given year)
month = january
era -> t
year -> 15
option2: keep the given fields as much as possible, set the default month to january, set the next available year in the same era if possible, if not, set next available era if possible, move to the previous era if possible.
e.g. if era = showa, year = 1, day_of_month = 25
day_of_month = 25 (given day)
month = january
year -> 2
era = s (given era)
option3: adding the day to the starting day then mod by number of day of starting month ..
day_of_month -> 20
month -> january
year -> 2
era = s
other options: there are many other options. Open for discussion.
================================================================
case 7: if ERA = given era, MONTH = given month, DAY = given day
================================================================
a) if given month = starting month of the era and given day is between starting day and the end of day of the starting month, stay the same implementation defined by current jdk, set the year to 1
b) others scenarios: (no preference for the following options)
option1: stay the same implementation defined by current jdk, which set year = 1 and normalize the era.
e.g. if era = showa, month = november, day_of_month = 20
day_month = 20
month = november (given month)
year -> 15
era -> t
option2: keep the given fields as much as possible, normalize the year first if necessary to stay in the given era, if not, normalize the era
e.g. if era = showa, month = november, day_of_month = 20
day_of_month = 20 (given day_of_month)
month = november (given month)
year -> 2
era = s (given era)
option3: stay the given day, using given month to find the year by adding given month to starting month then mod by 12. There are many ways to do this approach, but no matter what kind of approach is selected, needs to consistently apply to the other scenarios as much as possible.
e.g. if era = showa, month = november, day = 20
day_of_month = 20
month -> november
year -> 2
era = s (given era)
===================================================================================
case 8: if ERA = given era, YEAR = given year, MONTH = given month, DAY = given day
===================================================================================
a) if no conflict of the given date, nothing need to be done
b) if need to normalize the date, the common option is to normalize the era like current implementation of the jdk.
other options: there are many other options. Open for discussion.
Summary:
Personally, I think we should consider the first year as a special case . There are lots of other options open for many scenarios in each case. As long as it is clearly documented and the implementation is consistent, I personally have no preference one way or the other, as they all have pros and cons.
I close this rfe for now. There are couple of reasons.
The first reason is the huge work load it represents, they are 256 (2 to power of 8) ossible cases for me to consider about, the fields are limited to YEAR, MONTH, WEEK_OF_YEAR, WEEK_OF_MONTH, DAY_OF_MONTH (DATE), DAY_OF_YEAR, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH where ERA = 1. That is why I limited our discussion to demonstrate my suggestion here.
Secondly, so far we have not seen any complains or request from other customers. From business point of view, we probably should concentrate on our customer requests first.