[HTML] 纯文本查看 复制代码 private static void getBetweenTime(String start, String type)
throws ParseException {
SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Date begin = dfs.parse(start);
java.util.Date end = dfs.parse(getCurrentTime());
long between = (end.getTime() - begin.getTime()) / 1000;// 除以1000是为了转换成秒
long day1 = between / (24 * 3600);
long hour1 = between % (24 * 3600) / 3600;
long minute1 = between % 3600 / 60;
long second1 = between % 60 / 60;
System.out.println(type + "相差" + day1 + "天" + hour1 + "小时" + minute1
+ "分" + second1 + "秒");
} |