自定义工具类,获取当前时间到第二天的零点、下个月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);    } }
  • 2019-05-21 12:43:26

    (重要)RecycleView的缓存机制

    RecycleView的四级缓存是由三个类共同作用完成的,Recycler、RecycledViewPool和ViewCacheExtension。Recycler用于管理已经废弃或者与RecyclerView分离的ViewHolder,这里面有两个重要的成员,为可以看见的屏幕的内部缓存成员mAttachedScrap、mChangedScrap和滑出屏幕外的外部缓存成员mCachedViews二者共同完成ViewHolder的缓存;RecycledViewPool类是用来缓存整体所有的ViewHolder,是对mCachedViews缓存的补充;ViewCacheExtension是扩展内的缓存对象,默认不加载,需实现方法getViewForPositionAndType(Recycler recycler, int position, int type)来实现自己的缓存。接下来对四级缓存一步步介绍。

  • 2019-05-21 12:44:31

    对嵌套RecyclerView的优化

    RecyclerView 是一个更高级的 ListView ,它可以重用view避免额外创建太多的view从而带来流畅的滚动性能。RecyclerView通过叫做 View pool 的东西持有不再可见的 view ,让它可被回收

  • 2019-05-25 14:54:50

    commit your changes or stash them before you can merge

    Your local changes to the following files would be overwritten by merge:         protected/config/main.php Please, commit your changes or stash them before you can merge. --------------------- 作者:陈小峰_iefreer 来源:CSDN 原文:https://blog.csdn.net/iefreer/article/details/7679631 版权声明:本文为博主原创文章,转载请附上博文链接!

  • 2019-05-27 10:43:34

    IntelliJ IDEA中C盘文件过大怎么办

    当我在D:\ 安装完IDEA9.0之后,建立了一个工程,发现C:\Users\Administrator\.IntelliJIdea90 竟然增大到了500+M,并且随着使用在逐渐增大,这样占用系统盘资源是非常让人不爽的,那么如何将其修改到其他路径呢?

  • 2019-05-28 13:33:20

    BRVAH+MTRVA,复杂?不存在的

    言归正传,这样的一个首页,我们需要做怎么样的基础工作呢?或者说,碰到以后更复杂的页面我们应该怎么做?这里小提示下,不要再用什么类似ScrollView的这种东西了,诶,好像说的有点绝对,尽量不要用,这不是谷歌想要看到的,5.0谷歌推出了RecyclerView,从它的整个设计架构来看,简直就是为这而生的。而RecyclerView的视图是通过Adapter来渲染的。原始的Adapter,让人很蛋疼,重复工作太多,我们应该要有封装的思想,把最需要的部分提供出来,其它不用管。

  • 2019-05-29 14:19:19

    解决Git中fatal: refusing to merge unrelated histories

    Git的报错 在使用Git的过程中有时会出现一些问题,那么在解决了每个问题的时候,都需要去总结记录下来,下次不再犯。 一、fatal: refusing to merge unrelated histories 今天在使用Git创建项目的时候,在两个分支合并的时候,出现了下面的这个错误。

  • 2019-05-29 15:47:51

    撤销commit

    在git push的时候,有时候我们会想办法撤销git commit的内容