I have a Date object (java.sql.Date
). I need to get 12 at night of that day. So I can create a time period from current time to end of the day.
How can I calculate that time with java.sql.Date
. Please send me an example.
Using java.util.Calendar
java.sql.Date sqlDate = ...;
Calendar cal = Calendar.getInstance();
cal.setTime(sqlDate);
cal.add(Calendar.DAY_OF_YEAR,1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
java.sql.Date sqlTommorow = new java.sql.Date(cal.getTimeInMillis());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With