There is a java web site, jQuery datepicker is attached to the form. For sampling from the database, you need to compare 2 dates, or rather, there is a transition from one day to another, for example, there is a certain change 1 (its time is from 22-00 01/01/2016 to 7-00 02.01.2016).
On the form for displaying the report, you can choose absolutely any date and year, but if it is a shift 1, then you need to use the date of the next day instead of the current date.
How to implement it correctly? Change is defined as:
if (gang.equals("1")){time_start = "22:00:00"; time_end = "7:00:00";}