Good Day!
I have a problem with SQL Dates. I think the main problem is on the perspective of time.
In my program, I have a start and end date, say for example
The entire reason for java.sql.Date
to exist is that it does not allow hours minutes and seconds (As defined by the ANSI SQL Date type, and pretty much universally ignored by RDMBS implementors).
It is simply impossible to put the time in the database as long as you use java.sql.Date. If you want time, you need to switch to java.sql.Timestamp
.
If you're asking how to calculate the actual value of 'end of day', it's simplest to just go to the next day and subtract 1 millisecond.
Calendar cal = Calendar.getInstance();
cal.setTime(endDate);
cal.add(Calendar.DATE, 1);
java.sql.Timestamp endTime = new java.sql.Timestamp(cal.getTimeInMillis() -1L);