From 2818433841637ac5aaa8823f2904aec417ef72b7 Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Thu, 26 Aug 2021 16:23:20 +0800 Subject: [PATCH] kafka消费组配置文件 --- screen-common/src/main/java/com/moral/util/DateUtils.java | 43 +++++++++++++++++++++++++++++++++++-------- 1 files changed, 35 insertions(+), 8 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..9af501f 100644 --- a/screen-common/src/main/java/com/moral/util/DateUtils.java +++ b/screen-common/src/main/java/com/moral/util/DateUtils.java @@ -1,6 +1,7 @@ package com.moral.util; +import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; import java.math.BigDecimal; @@ -13,7 +14,7 @@ import java.time.ZonedDateTime; import java.util.*; - +@Slf4j public class DateUtils { /** * ������������(yyyy) @@ -79,11 +80,33 @@ * ������������(yyyy-MM-dd HH) * */ public static final String yyyy_MM_dd_HH_EN = "yyyy-MM-dd HH"; + + /* + * Date���toString������ + * */ + public static final String EEE_MMM_dd_HH_mm_ss_zzz_yyyy = "EEE MMM dd HH:mm:ss zzz yyyy"; /** * DateFormat������ */ private static Map<String, DateFormat> dateFormatMap = new HashMap<String, DateFormat>(); + + /** + * @Description: Date���toString������������Date + * @Param: [] + * @return: java.util.Date + * @Author: ��������� + * @Date: 2021/8/25 + */ + public static Date dateStringToDate(String formatStr){ + try { + SimpleDateFormat sdf = new SimpleDateFormat(EEE_MMM_dd_HH_mm_ss_zzz_yyyy, Locale.US); + return sdf.parse(formatStr); + } catch (ParseException e) { + log.error(e.getMessage()); + return null; + } + } /** * ������DateFormat @@ -1358,7 +1381,7 @@ /* * ������������������������������������ - * ������time=2021-08-04 ��������������������������������������� + * ������time=2021-08-04 ���������������������������������������2021-08-04 00���2021-08-04 01��������� * time=2021-08 ��������������������������������� * */ public static List<String> getTimeLag(String time) { @@ -1367,23 +1390,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; -- Gitblit v1.8.0