获取第二天凌晨12点时间

/**
* 获取明天的凌晨12点时间戳
* @return
*/
public static long getTomorrowBegin() {
long now = System.currentTimeMillis() / 1000l; 
long daySecond = 60 * 60 * 24; 
long dayTime = now - (now + 8 * 3600) % daySecond + 1*daySecond;
return dayTime;
}

daySecond 一天的秒数, 加8原因  1970-1-1 08:00:00 多了8个小时,所以必须多减掉8个小时,开始也没有明白,后面new Date(0) 得出时间就是1970-1-1 08:00:00

猜你喜欢

转载自blog.csdn.net/xiaozuoay/article/details/80527374