SimpleDateFormat df = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);
java.util.Date now = df.parse(“2019-07-24 00:00:00”);
java.util.Date date=df.parse(“2019-07-24 08:10:10”);
long l=now.getTime()-date.getTime();
long day=l/(2460601000);
long hour=(l/(60601000)-day24);
long min=((l/(601000))-day2460-hour60);
long s=(l/1000-day246060-hour6060-min60);
System.out.println(""+day+“天”+hour+“小时”+min+“分”+s+“秒”);
System.out.println("=========================第二种");
SimpleDateFormat dfs = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);
java.util.Date begin=dfs.parse(“2019-07-24 00:00:00”);
java.util.Date end = dfs.parse(“2019-07-24 08:10:10”);
long between=(end.getTime()-begin.getTime())/1000;//除以1000是为了转换成秒
System.out.println(“between:”+between);
long day1=between/(24*3600);
long hour1=between%(24*3600)/3600;
long minute1=between%3600/60;
long second1=between%60;
System.out.println(""+day1+"天"+hour1+"小时"+minute1+"分"+second1+"秒");