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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Ideally, use Joda Time which is a much better date and time API than the one in Java.
Note that this assumes UTC everywhere… whereas I suspect you want midnight local time in which case you’ll need to specify the time zone. Also note that midnight doesn’t always occur on every day in all time zones due to daylight saving time – the above code will give you the start of the day instead.