81,092
社区成员
发帖
与我相关
我的任务
分享
SimpleDateFormat matter1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//格式化时间格式
Date nowTime=new Date();//获取当前时间
String tmf= matter1.format(nowTime);
Date now=matter1.parse(tmf);
Date end=matter1.parse(atime);//atime是数据库中事前存的时间
long cha=(now.getTime()-end.getTime())/ (1000 * 60 * 60 * 24);//计算时间差
System.out.println("一号时间差事:"+cha);