From 4784ba9b5fe0d2c9ada694834ac6b0d0b7474b89 Mon Sep 17 00:00:00 2001 From: lizijie <lzjiiie@163.com> Date: Thu, 12 Aug 2021 15:52:23 +0800 Subject: [PATCH] special_device、special_device_history相关文件,special_device查询接口 --- screen-common/src/main/java/com/moral/util/DateUtils.java | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) diff --git a/screen-common/src/main/java/com/moral/util/DateUtils.java b/screen-common/src/main/java/com/moral/util/DateUtils.java index 7fe7e86..51034a8 100644 --- a/screen-common/src/main/java/com/moral/util/DateUtils.java +++ b/screen-common/src/main/java/com/moral/util/DateUtils.java @@ -1367,23 +1367,27 @@ Calendar cal = Calendar.getInstance(); String end; String dateFormat; + String df; int i; if (length == 10) {//��� end = getDateAddDay(time, 1); - dateFormat = yyyy_MM_dd_EN; + dateFormat = yyyy_MM_dd_HH_EN; + df = yyyy_MM_dd_EN; i = Calendar.HOUR_OF_DAY; } else if (length == 7) {//��� end = getDateAddMonth(time, 1); - dateFormat = yyyy_MM_EN; + dateFormat = yyyy_MM_dd_EN; + df = yyyy_MM_EN; i = Calendar.DAY_OF_MONTH; } else {//��� end = getDateAddYear(time, 1); - dateFormat = yyyy; + dateFormat = yyyy_MM_EN; + df = yyyy; i = Calendar.MONTH; } - cal.setTime(getDate(time, dateFormat)); - for (long d = cal.getTimeInMillis(); d < getDate(end, dateFormat).getTime(); cal.set(i, cal.get(i) + 1), d = cal.getTimeInMillis()) { - String format = dateToDateString(new Date(d)); + cal.setTime(getDate(time, df)); + for (long d = cal.getTimeInMillis(); d < getDate(end, df).getTime(); cal.set(i, cal.get(i) + 1), d = cal.getTimeInMillis()) { + String format = dateToDateString(new Date(d),dateFormat); result.add(format); } return result; @@ -1403,4 +1407,8 @@ stringBuffer.replace(15, 16, String.valueOf(i)); return getDate(stringBuffer.toString(), yyyy_MM_dd_HH_mm_EN); } + + public static void main(String[] args) { + System.out.println(getTimeLag("2021")); + } } -- Gitblit v1.8.0