标签:led type imp static return star nbsp 时间间隔 catch
/** * 计算两个时间间隔 * @param startTime 开始时间 * @param endTime 结束时间 * @param type 类型(1:相隔小时 2:) * @return */ public static int compareTime(String startTime, String endTime, int type) { if (endTime == null || "".equals(endTime)) { endTime = getCurrentTime(); } SimpleDateFormat sdf = DateFormatUtils.getFormat(""); int value = 0; try { Date begin = sdf.parse(startTime); Date end = sdf.parse(endTime); long between = (end.getTime() - begin.getTime()) / 1000L; if (type == 1) { value = (int)(between % 864000L / 3600L); } else if (type == 2) { value = (int)(between % 3600L / 60L); } else if (type == 3) { value = (int)(between % 60L / 60L); } } catch (ParseException var9) { var9.printStackTrace(); } return value; }
标签:led type imp static return star nbsp 时间间隔 catch
原文地址:https://www.cnblogs.com/chenchengxuyuan/p/10698356.html