自定义工具类,获取当前时间到第二天的零点、下个月1号零点的时间差(s):

2018-03-14 11:31:09
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);    } }
  • 2020-06-20 06:31:16

    mac下全局配置adb环境

    不提示“command not found”,而是出现一长串帮助说明,那就证明adb已经配置好了。

  • 2020-06-20 06:31:39

    Android 无线调试手机(WiFi 调试)

    手机需要开启 USB 调试 手机和电脑要在同一个局域网(连接同一个 WiFi) adb connect 连接成功后要拔出 USB 线,不然出现同时连接两个设备的问题 执行命令 ”adb tcpip 6666“ 后可能需要重新开启 USB 调试

  • 2020-08-16 16:09:30

    android WebView 注入js 几种方式

    有时我们开发中需要将js 注入到我们本地,有可能你会说,放在Web不就可以了吗,的确,但是需求就是这样的

  • 2020-11-05 23:20:29

    mac更新node版本

    initializer function 0x0 not in mapped image for /usr/local/bin/node,除了上面的问题 你或许还出现过 no such file or directory 这样的提示,总之更新完以后node直接不能用了。

  • 2020-11-07 16:31:02

    nginx配置X-Frame-Options允许多个域名iframe嵌套

    有时候我们需要允许多个url的来源,但是又不能全部开放,所以应该匹配第三种方法ALLOW-FROM url,那么多个url该如何配置呢,百度了所有网站都没有找到,那么这里写给大家,其实很简单: add_header X-Frame-Options 'ALLOW-FROM https://xxx.xxxxxx.com https://xxx2.xxxxxxx.com'; 就是使用空格隔开就好了!

  • 2020-11-08 08:31:51

    meteor在不同端口启动服务

    当没有任何参数时,run是默认行为,在幕后,它3000端口开启node.js服务器实例,同时开启监听3001端口的MongoDB服务