[threeten-dev] Handling Leap Month in Chronology subclass
Stephen Colebourne
scolebourne at joda.org
Tue Dec 4 10:20:38 PST 2012
On 4 December 2012 13:48, <yoshito_umaoka at us.ibm.com> wrote:
> I have one question about implementing Chronology subclass supporting
> Chinese calendar and its variants.
>
> Chinese calendar is a lunisolar calendar system and leap month might be
> inserted at certain rule. It differs from Hijrah calendar that insert leap
> month at the end of year cycle (13th month).
> In ICU project, we found than leap months in Chinese calendar require
> extra field to indicate leap month. This is doable with java.util.Calendar
> subclass, although additional field is a little bit tricky.
>
> I'm wondering if there is a good way to support such calendar with JSR-310
> Chronology without messing up month numbering.
I think this is a good question.
My feeling is that an additional field that only has meaning in the
Chinese calendar system is hard for users, as the vast majority of
users won't know it exists, and thus end up with the wrong date in
calculations.
The main alternatives are
- the month-of-year is a count rather than with reference to the local
month number. So if the months go 1,2,3,3,4,5 then the count would go
1,2,3,4,5,6
- the extra month is treated as additional days of the month. So
rather than having 30 days, the month has 60 days (or whatever the
correct rule is).
Neither of these are pretty or nice, but they are effective (on the
development side).
The second part of the problem is then mapping the value back to
something meaningful during printing/parsing. I suspect that the
additional days-of-month approach is easier to process. eg
if (dayOfMonth > 30) {
// output month indicator and (dayOfMonth - 30)
} else {
// dayOfMonth
}
However I do not know without further consideration what would could
be used to trigger this logic.
Look forward to your other comments.
Stephen
More information about the threeten-dev
mailing list