I am trying to figure out the math to verify shifts are getting correct breaks, when I query the api I get the following response:
"StartDate": "4/25/2018",
"EndTime": "8:30PM",
"StartDayNumber": 1,
"StartTime": "7:30PM",
"SegmentTypeName": "BREAK",
"EndDate": "4/25/2018",
"EndDayNumber": 1
I have tried various attempts at using LocalTime
so I can use the function Duration
:
LocalTime start = LocalTime.parse(employeeShift.getJSONObject(ii).get("StartTime").toString(), DateTimeFormatter.ofPattern("HH:mm a"));
LocalTime end = LocalTime.parse(employeeShift.getJSONObject(ii).get("EndTime").toString());
I have tried various way to convert EndTime and StartTime to a local time. However I am stumped I have tried a various number of formatters including the day, the hour but I have not found an example that included the am/pm, do I need to convert to 24 hour time first?
The error I've got:
java.time.format.DateTimeParseException: Text '1:00PM' could not be parsed at index 0