java - Ordinal hour-of-day "Hour Ending" conversion to date-time value -
some businesses track events in time "hour ending". each hour of day represented ordinal number:
- 1…24 utc
- 1…23, 1…24, , 1…25 time zones one-hour daylight saving time (dst) adjustment.
so first hour of day, midnight 01:00 hour ending 01.
to me, seems silly way track time. more sensible using time-of-day half-open approach, [), beginning inclusive, , ending exclusive. so:
2014-12-05t01:00:00.000markhour ending 012014-12-06t00:00:00.000(midnight) markhour ending 24.
indeed, want store in database (postgres), timestamp time zone value converted date & ordinal hour number. question is:
given date , ordinal "hour ending" number (1…23/24/25 locality 1-hour dst), how convert date-time value?
i'm familiar joda-time , java.time. either of them offer way convert? if not, kind of algorithm handles both ordinal number conversion , dst?
or should not fight this, , store local date string suffix of ordinal hour number?
perhaps java.time method looking truncatedto, can used take zoneddatetime , truncate minutes , seconds
zoneddatetime zdt = zoneddatetime.now(); zoneddatetime rounded = zdt.truncatedto(chronounit.hours); zoneddatetime hourend = rounded.plushours(1);
Comments
Post a Comment