欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

获取相隔天数,相隔天数,//获取相隔天数 /*

来源: javaer 分享于  点击 13971 次 点评:155

获取相隔天数,相隔天数,//获取相隔天数 /*


//获取相隔天数  /**get the days of the gap of the tow date * @param beforedate * @param afterdate * @return * @throws ParseException */static public long getDistinceDay(String beforedate, String afterdate) throws ParseException {      SimpleDateFormat d = new SimpleDateFormat("yyyy-MM-dd");      long dayCount=0;     try{         java.util.Date d1 = d.parse(beforedate);         java.util.Date d2 = d.parse(afterdate);         dayCount = (d2.getTime()-d1.getTime())/(24*60*60*1000);     }catch(ParseException e){         System.out.println("Date parse error!");     }     return dayCount;  }//该片段来自于http://byrx.net
相关栏目:

用户点评