29 hour day or how to rollover day at a time other than midnight?

2013-12-30
2014-02-06
  • Menno M Jansz

    Menno M Jansz - 2013-12-30

    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?

     
  • Stephen Colebourne

    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.

     
  • Menno M Jansz

    Menno M Jansz - 2014-02-06

    Hi Stephen,

    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.

    Cheers,
    Menno

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks