[Solved] Subtract 6 hours from an existing Date object java (midnight corner case)


No.

After running the following code:

Date birthDate = (...say Apr 20th 0300hrs)
Calendar cal = Calendar.getInstance();
cal.setTime(birthDate);
cal.add(Calendar.HOUR, -6);

you are guaranteed that cal is set to six hours before ‘Apr 20th 0300hrs’, but not that it is set to ‘Apr 19th 2100hrs’.

4

solved Subtract 6 hours from an existing Date object java (midnight corner case)