Hi in DB i have four columns to store a time window. This would allow user to store 9:00 to 5:00 EST.
Now i need to parse this information in java.
java.sql.Time startTS = rs.getTime("begin_TIME ");
LocalTime localTime = startTS.toLocalTime();
offset could be made with: OffsetTime of(LocalTime time, ZoneOffset offset)
from what i see we cant convert zoneid to zoneoffset, so how do i 9:00 est(stored in time and zone columns) from sqlserver to java.
DB Table:
begin_TIME time NOT NULL,
begin_TIME_ZONE varchar(5) NOT NULL,
end_TIME time NOT NULL,
end_TIME_ZONE varchar(5) NOT NULL,
In the back-end I need to check that the request is in the window, request time is converted to ZonedDateTime and start and end need to come from DB:
public boolean compare(ZonedDateTime dateTime, OffsetTime startTime, OffsetTime endTime) {
OffsetTime offsetTime = dateTime.toOffsetDateTime().toOffsetTime();
int start = offsetTime.compareTo(startTime);
int end = offsetTime.compareTo(endTime);
return start >= 0 && end <= 0;
}