public Long milliSeconds (){
Long milliSeconds = 0L;
SimpleDateFormat formate = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Date now = new Date();
Long nowMillis = now.getTime();
String today = formate.format(now);
try {
Date end = dfs.parse(today + " 23:59:59.999");
Long endMillis = end.getTime();
milliSeconds = endMillis-nowMillis;// 得到两者的毫秒数
} catch (Exception ex) {
ex.printStackTrace();
}
return milliSeconds;
}
当前时间到凌晨的毫秒数
最新推荐文章于 2023-06-30 09:09:53 发布