Are there any good resources for Joda-Time custom timelines?

I am working on an RPG-style game and I want to develop a custom calendar for the game with unique months, weeks, monthly lengths and daily lengths. At first, I planned to redefine the JDK calendar and try to do it this way; however, I came across Joda-Time, and for this purpose it seemed more promising and powerful. However, it’s hard for me to understand how to create my own chronology, and I was wondering if there are good resources (which I can’t find) that explain how to create a chronology.

I tried to come up with an overloaded AssembledChronology, but it seems that it cannot satisfy my needs. And the idea of ​​what I want is a 9-month Calendar with 40 days a month, 10 days a week. In addition to this, there is a final “monthly” 10th month per year that lasts only 5 days.

Any help / advice is appreciated.

+4
source share
1 answer

My advice: do not try to do this with Joda Time.

It may be possible - although a month without menstruation sounds a bit strange - and Joda Time is definitely built on flexibility ... but dive into all the work AssembledChronology , DelegatedDateTimeField , DecoratedDateTimeField , etc. will probably make your head. Oh, and then you need the ability to create time zones.

Your calendar sounds pretty simple to be honest - it's simple enough that implementing a simple API from scratch might be easier than trying to understand the Joda Time implementation in detail.

Don't get me wrong: I love Joda Time in terms of using it for regular business applications. This is much better than Date and Calendar , in fact there is no going back once you started using it, but it is difficult.

(Just in terms of context, I'm moving Joda's time to .NET, or at least part of the “engine.” It’s well documented, but there really are large inheritance hierarchies, and it’s just not conducive to “just” creating a new system In the end, it may not take a lot of code, after all, for those who already know the details of Joda Time, but this is quite complicated, otherwise I would just try to avoid it.)

Of course, it really depends on how rich the API you need. If you really want the full power of Joda Time, then installing your calendar system will actually be easier than reimplementing the entire API. On the other hand, if you basically only after you said: “Here is the date in my regular calendar,” then there are simpler ways to achieve it. What do you really need in terms of date / time arithmetic in your game?

+3
source

All Articles