阅读背景:

Java ---MyUtil工具类

来源:互联网 

1.比拟一个yyyy-MM-dd类型的字符串日期与当前日期的时光差

public static int between(String s) throws ParseException{
// 我这里参很多天期大于当前日期,否则盘算式负数(你可以Math.abs(long)取绝对值)
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
   Calendar c = Calendar.getInstance();
   c.setTime(sdf.parse(s));
   long star = c.getTimeInMillis();
   Date d = new Date();
   c.setTime(sdf.parse(sdf.format(d)));
   long end =  c.getTimeInMillis();
   int a = Integer.parseInt(String.valueOf((star - end )/(1000*3600*24)));
   return a;
}

public static i




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: