自定义工具类,获取当前时间到第二天的零点、下个月1号零点的时间差(s):
cacheManager.set(monthKey, totalMonCount.toString(), DateUtil.getSecsToEndOfCurrentDay());public class DateUtil {
/**
*获取每月最后一天时间
* @param sDate1
* @return
*/
public static Date getLastDayOfMonth(Date sDate1) {
Calendar cDay1 = Calendar.getInstance();
cDay1.setTime(sDate1); final int lastDay = cDay1.getActualMaximum(Calendar.DAY_OF_MONTH);
Date lastDate = cDay1.getTime();
lastDate.setDate(lastDay); return lastDate;
} /*
获取下一个月第一天凌晨1点
*/
public static Date nextMonthFirstDate() {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 1); //设置为每月凌晨1点
calendar.set(Calendar.DAY_OF_MONTH, 1); //设置为每月1号
calendar.add(Calendar.MONTH, 1); // 月份加一,得到下个月的一号// calendar.add(Calendar.DATE, -1); 下一个月减一为本月最后一天
return calendar.getTime();
} /**
* 获取第二天凌晨0点毫秒数
* @return
*/
public static Date nextDayFirstDate() throws ParseException {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DAY_OF_YEAR, 1);
cal.set(Calendar.HOUR_OF_DAY, 00);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0); return cal.getTime();
} //*********
/**
* 获取当前时间到下个月凌晨1点相差秒数
* @return
*/
public static Long getSecsToEndOfCurrentMonth(){
Long secsOfNextMonth = nextMonthFirstDate().getTime(); //将当前时间转为毫秒数
Long secsOfCurrentTime = new Date().getTime(); //将时间转为秒数
Long distance = (secsOfNextMonth - secsOfCurrentTime)/1000; if (distance > 0 && distance != null){ return distance;
} return new Long(0);
} /**
* 获取当前时间到明天凌晨0点相差秒数
* @return
*/
public static Long getSecsToEndOfCurrentDay() throws ParseException {
Long secsOfNextDay = nextDayFirstDate().getTime(); //将当前时间转为毫秒数
Long secsOfCurrentTime = new Date().getTime(); //将时间转为秒数
Long distance = (secsOfNextDay - secsOfCurrentTime)/1000; if (distance > 0 && distance != null){ return distance;
} return new Long(0);
}
}
-
vagrant up 失败解决办法
直接使用VirtualBox开启一个vm也会失败,基本上可以确定是VirtualBox版本的问题 有遇到过安装了VirtualBox-5.0.22-108108-Win.exe的版本在win7下用不了,卸载重装VirtualBox-4.3.12-93733-Win.exe之后可用。
-
vue过渡和animate.css结合使用
vue过渡和animate.css结合使用
-
'gulp'不是内部或者外部命令,也不是可运行的程序或批处理文件
获得npm全局变量的方法,设置npm全局变量的方法。
-
php7.0升级php7.2
看电脑上的教程要备份7.0配置文件以及扩展啥的,我感觉不如卸载干净重新安装
-
分页优化的四种方式
在大数据量的情况下,原本很简单的分页如果没有处理好,你会发现分页的请求会消耗你大量的数据库时间。如果你遇到了这个问题,文章给了你几个很好的解决的方案。当然,初学者若能看完这篇文章,那么它会指导你写出更具有扩展性的分页代码。
-
include(C:\\work\\blog): failed to open stream: Permission denied
laravel搭建的程序无缘无故的变成了,include(C:\\work\\blog): failed to open stream: Permission denied
-
js获取上一页、当前页及域名url方法,JS反回上一页的方法
js获取上一页、当前页及域名url方法,JS反回上一页的方法
-
js如何判断是否在iframe中及防止网页被别站用iframe嵌套
本文主要介绍了js判断是否在iframe中及防止网页被别站用 iframe嵌套的方法。具有很好的参考价值,一起来看下吧
-
laravel Eloquent 如何实现 FIND_IN_SET ,并实现分页
有个文章表里面有个type字段,他存储的是文章类型,有 1头条,2推荐,3热点,4图文 .....11,12,13等等 现在有篇文章他既是 头条,又是热点,还是图文,
-
MySQL关于根据日期查询数据的sql语句
MySQL关于根据日期查询数据的sql语句