I have a timestamp in milliseconds that is 1349557200000. How can I check that it occurs at midnight at my current time zone?
The best I’ve come up with is something like:
Calendar mycal = Calendar.getInstance();
Integer offset = (mycal.get(Calendar.ZONE_OFFSET) + mycal.get(Calendar.DST_OFFSET)) * (60 * 1000);
Boolean isAtMidnight = 1349557200000L % (24L * 60L * 60L * 1000L)) == (long) offset ? true : false;
This looks a tad complicated. I was wondering if there are any shortcut methods that I might be missing. Thanks.
1 Answer