java倒计时

来源:互联网 发布:如何安装管家婆数据库 编辑:程序博客网 时间:2024/06/06 07:26
@Transient
    public Integer getRemainDays() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar cal = Calendar.getInstance();
        try {
            String today = DateUtil.getCurrentDatetime();
            cal.setTime(sdf.parse(today));
            long time1 = cal.getTimeInMillis();
            cal.setTime(sdf.parse(manitEnddate));
            long time2 = cal.getTimeInMillis();
            long between_days = (time2 - time1) / (1000 * 3600 * 24);
            return Integer.parseInt(String.valueOf(between_days));
        } catch (ParseException e) {
            e.printStackTrace();
            return 0;
        }
    }
0 0
原创粉丝点击