I am defining my data at this time, in a Java application using a MySQL database. One of the kinds of data that I need is a date/time period. I need to store additive amounts in date-time.
I am otherwise planning to use Java LocalDateTime and MySQL's TIMESTAMP data type for storing date/times. I plan to convert LocalDateTime using the Java Timestamp functions.
Can I store a period in a MySQL TIMESTAMP? How would it handle "1 day, 3 hours, and 6 minutes" as a TIMESTAMP (without being in an epoch)? If not, what would work well with the Java approach I am using? TIA.
DETAILS edit-added:
This is for local use, in one time zone per distribution. The Java app on PCs is where LocalDateTime will be captured and viewed via my Java GUI, where the needed granularity will be no finer than minutes. Then, they get stored in the DB as TIMESTAMP.
The periods will be stored in a "shift template" table in the DB, as start and end time periods relative to the zero-point of the template, for each shift in one cycle of shifts. I will calculate all "Shift" records (in Java) from a given start date-time, to some number of months in advance, by looped processing of these shift template records.
Example of use: This sample template will define 12-hour shifts, day and night, for 8 days, for 4 crews, with each getting 4 days on and then 4 days off (16 records in this template table). All values are add-amounts to the caller's zero point. Each preset template record contains:
- add-amount for shift number
- time-date add-amount for start of shift
- time-date add-amount for end of shift
- a crew identifier for the shift
Grid Template (records)
(Time periods are shown as DD:hh:mm)
Shift 01: 00:00:00 – 00:12:00, crew A
Shift 02: 00:12:00 – 01:00:00, crew B
Shift 03: 01:00:00 – 01:12:00, crew A
…
Shift 09: 04:00:00 – 04:12:00, crew C
Shift 10: 04:12:00 – 05:00:00, crew D
… (up to shift 16)
Next are the shift records I would like to produce from the above template record set, using 06/01/2016 06:00 as an example starting date-time (or zero point), with:
- Shift number
- Shift starting date-time
- Shift ending date-time
- Crew identifier for the shift
Shift (records)
(Date-times are shown as MM/DD/YYYY hh:mm)
Shift 01: 06/01/2016 06:00 – 06/01/2016 18:00, crew A
Shift 02: 06/01/2016 18:00 – 06/02/2016 06:00, crew B
Shift 03: 06/02/2016 06:00 – 06/02/2016 18:00, crew A
…
Shift 09: 06/05/2016 06:00 – 06/05/2016 18:00, crew C
Shift 10: 06/05/2016 18:00 – 06/06/2016 06:00, crew D
…
Shift 17: 06/09/2016 06:00 – 06/09/2016 18:00, crew A
Shift 18: 06/09/2016 18:00 – 06/10/2016 06:00, crew B
…
Shift 25: 06/13/2016 06:00 – 06/13/2016 18:00, crew C
Shift 26: 06/13/2016 18:00 – 06/14/2016 06:00, crew D
…
Edited throughout, from "offset" to "period", with some clarification
TimeUnitenum.LocalDateTimeandTimeUnitfor converting to and fromint, where only as fine as minutes are preserved, I would be happy to accept that as an answer.