Search code examples
javacalendarjodatimechinese-locale

How to use the Chinese calendar system in Joda Time?


I'm developing a calendar app that needs to convert dates from other calendar systems to Gregorian dates. So I decided to use JodaTime.

Soon I found that different calendar systems are represented as Chronologys. And I looked through the list of Chronologys and see nothing about the Chinese Calendar system aka Lunar Calendar. Then I searched for "Lunar Calendar Joda Time" and I see IslamicChronology but I don't think that is the right one as it says on the page that this is used in Muslim countries.

So I'm not really sure how to use Chinese Calendar system using Joda Time. I also looked at another Stack Overflow post which suggests that I should use another library. However, Joda Time does not seem to have an interface to support that library which means I cannot be consistent. Some of the project I use Joda Time and some of it I don't. It just sounds weird to me.


Solution

  • The only library which has support is ICU4J as far as I know. A strength of that library is extended i18n-support. Disadvantage is the API itself which is similar to java.util.Calendar.

    Joda-Time does not support it and has no plans, too (since it is officially a "largely finished" project, the project owner recommends to implement any new calendars on the base of Threeten-Extra and welcomes any contributions of the community). It is also not so easy to implement it on the base of Joda-Time from the scratch - an important reason why Joda-Time does not support so many calendars. I18n is also not a strength.

    My library Time4J will certainly implement it in the future including i18n-features (probably next year due to my limited working capabilities) so you might watch any activities there.

    There is also a very old issue on JDK-bug-log. I think our hopes for the JDK implementing this calendar is tending towards zero. Sorry for the negative answer.

    Update from 2018-03-07:

    Still no news from Joda, but now my library Time4J finally supports the Chinese calendar offering a more accurate alternative to ICU4J.