自定义工具类,获取当前时间到第二天的零点、下个月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-03-20 13:39:50

    类似与微信朋友圈功能数据库如何实现

    每次发圈子的时候,给关注我的每个uuid,发一个内容id。 大概表的设计就是 uuid,idlist 这样的,idlist是按照时间顺序的。 然后定期删除idlist过多的老圈子。

  • 2020-03-21 00:11:38

    Android卡片布局(圆角阴影)的几种实现及分析

    在开发中,为了界面美观,圆角view和阴影效果是开发中经常遇到的UI场景,比如银行卡效果,卡片式itemView布局,Banner图等,开发中我们通过各种方式实现了这种效果,但是哪种方案最好呢,接下来本文将比较几种常见的圆角阴影布局实现,并从内存占用角度分析它们的优缺点.

  • 2020-03-21 12:05:24

    android 自定义组件,使用AttributeSet

    首先要在res/values目录下建立一个attrs.xml(名字可以自己定义)的文件,并在此文件中增加对控件的属性的定义.其xml文件如下所示:

  • 2020-03-21 12:09:59

    Android使用AttributeSet自定义控件的方法

    我们可以在attrs.xml中声明自己控件的属性,在布局xml文档中声明自己的命名空间,这时就可以对设置自己想要的值了,然后在AttributeSet这个属性中获取对应的值。好了不多说,我们来看下代码,一切尽在不言中:

  • 2020-03-22 21:16:07

    用vue做的跟随鼠标移动的div

    最近接到一个任务,就是在既存用electron-vue开发的桌面端程序上追加随鼠标移动的动画效果,之前一直使用angular和react,没怎么接触过vue,先做一个vue的简单例子,然后再整合。

  • 2020-03-23 15:16:30

    import,require具体用法

    import 和 require 是JS模块化编程使用的,是前端开发者们在性能探索中的又一大进步。