From d524949baa3b1c64da27f9b5592a1d94845849c6 Mon Sep 17 00:00:00 2001 From: kaiyu <404897439@qq.com> Date: Thu, 05 Aug 2021 17:07:47 +0800 Subject: [PATCH] screen-api 实时界面对数据进行保留小数位并且取整 --- screen-common/src/main/java/com/moral/util/DateUtils.java | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 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 8e61079..9281bed 100644 --- a/screen-common/src/main/java/com/moral/util/DateUtils.java +++ b/screen-common/src/main/java/com/moral/util/DateUtils.java @@ -1355,4 +1355,37 @@ } return date; } + + /* + * ������������������������������������ + * ������time=2021-08-04 ��������������������������������������� + * time=2021-08 ��������������������������������� + * */ + public static List<String> getTimeLag(String time) { + List<String> result = new ArrayList<>(); + int length = time.length(); + Calendar cal = Calendar.getInstance(); + String end; + String dateFormat; + int i; + if (length == 10) {//��� + end = getDateAddDay(time, 1); + dateFormat = yyyy_MM_dd_EN; + i = Calendar.HOUR_OF_DAY; + } else if (length == 7) {//��� + end = getDateAddMonth(time, 1); + dateFormat = yyyy_MM_EN; + i = Calendar.DAY_OF_MONTH; + } else {//��� + end = getDateAddYear(time, 1); + dateFormat =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)); + result.add(format); + } + return result; + } } -- Gitblit v1.8.0