I\'m experiencing a very weird behaviour while saving dates on database. On my (Linux centOS 6.2) server I use glassfish application server (3.1.1 - build 12) and Java (1.7.
Faced this issue in real time for date of birth.
I did the below fix, so that instead of saving a date at 12 am, date will be saved at 6 am which is before business hours of server. Even an hour is deducted, it won’t affect dob.
Calendar now = Calendar.getInstance();
now.setTime(YOUR_DATE);
now.set(Calendar.HOUR_OF_DAY, 6);
YOUR_DATE = now.getTime();
Mikes answer is fine. But, if we save with 12 pm, there is a possibility for error in date comparison, if user enters date during business hours before 12 pm.