I have a situation were I need to implement datetime code where the day does not roll over at midnight, but at 6am instead.
It is how advertisers view a day. They have a concept were the day starts at 06:00 and ends at 29:59. They view midnight as an inappropriate arbitrary point to divide a day and that 6am is more appropriate.
So in their view a time of 25/10/2013 24:00 is actually 26/10/2013 00:00 in ISO time, and similarly 25/10/2013 29:59 is actually 26/10/2013 05:59 in ISO time.
I've looked at the ISOChronology class, but unsure how I can implement this using Joda time. Any recommendations on how to do it?
This should be possible but will require writing a whole chronology. Lots of the ISO chronology should be re-usable, but chronologies are complex beasts and not much documented. The main aspects will be changing the HourOfDay min/max values and adjusting the result value in the DateTimeField. However, you'll also need to change the other fields such as DayOfMonth, MonthOfYear and Year to handle the alternate switchover.
Thanks for the pointers. I did dive into the code already to look what needed to be done, but concluded it was more complicated to take on than I had time for. Also project deadlines looming, so I ended up creating my own time class and using LocalDate with it.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.