如何检查当前时区的毫秒时间戳是否在午夜?

Mri*_*lla 2 java time

我有一个以毫秒为单位的时间戳1349557200000.如何检查它是否出现在我当前时区的午夜?

我提出的最好的是:

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;
Run Code Online (Sandbox Code Playgroud)

这看起来有点复杂.我想知道是否有任何我可能缺少的快捷方法.谢谢.

JB *_*zet 9

Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(milliseconds);
return cal.get(Calendar.HOUR_OF_DAY) == 0
       && cal.get(Calendar.MINUTE) == 0
       && cal.get(Calendar.SECOND) == 0
       && cal.get(Calendar.MILLISECOND) == 0;
Run Code Online (Sandbox Code Playgroud)