开发者

Are there good resources for custom Joda-Time Chronologies?

I'm working on an RPG style game and I want to develop a custom Calendar for the game with unique months, week-days, month lengths, and day lengths. I was planning开发者_如何学C originally to override the JDK Calendar and attempt to do it that way; however, I ran across Joda-Time and it seemed more promising and powerful for this purpose. However, I'm having trouble figuring out to create my own Chronology and was wondering if there were good resources (that I can't seem to find) that explain how to create a Chronology.

I've tried come up with an overloaded AssembledChronology but can't seem to get it to fit my needs. And idea of what I want is a 9 month Calendar with 40 days a month, 10 days a week. In addition to that, there is a final "monthless" 10th month per year that only lasts 5 days.

Any help/advice is appreciated.


My advice: don't try to do it with Joda Time.

It may be possible - although a "monthless" month sounds a little odd - and Joda Time is certainly built on flexibility... but getting your head round all of the business of AssembledChronology, DelegatedDateTimeField, DecoratedDateTimeField etc is likely to do your head in. Oh, and then you need the possibility of time zones.

Your calendar sounds quite simple to be honest - sufficiently simple that implementing a straightforward API from scratch may well be simpler than trying to understand the implementation of Joda Time in detail.

Don't get me wrong: I love Joda Time in terms of using it for normal business applications. It's so much better than Date and Calendar, there's really no turning back once you've started using it - but it is complicated.

(Just in terms of context, I'm porting Joda Time to .NET, or at least the "engine" part of it. It's fairly well documented but there are large inheritance hierarchies all over the place, and it's just not conducive to "just" creating a new calendar system. It may well not take a lot of code in the end for someone who already knows the details of Joda Time, but it's sufficiently tricky otherwise that I'd just try to avoid it.)

Of course, it really depends on how rich an API you need. If you really want all the power of Joda Time, then fitting your calendar system in would indeed be simpler than re-implementing all of the API yourself. On the other hand, if you're mostly just after a way of saying, "Here's a date in my custom calendar" then there are simpler ways of achieving it. What do you really need in terms of date/time arithmetic in your game?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜