diff --git a/LOG.md b/LOG.md index a6857bc..6ccd540 100644 --- a/LOG.md +++ b/LOG.md @@ -10,6 +10,8 @@ ## v2.2.5 +- DateTimeUtils 新增可根据时间戳获取当天最大或最小的方法 + ## v2.2.4 diff --git a/src/main/java/com/fengwenyi/javalib/convert/DateTimeUtils.java b/src/main/java/com/fengwenyi/javalib/convert/DateTimeUtils.java index 5e67ae3..a727522 100644 --- a/src/main/java/com/fengwenyi/javalib/convert/DateTimeUtils.java +++ b/src/main/java/com/fengwenyi/javalib/convert/DateTimeUtils.java @@ -408,4 +408,31 @@ public static boolean judgeInTimeDurationWithBoundary(LocalTime time, LocalTime return time.compareTo(startTime) >= 0 || time.compareTo(endTime) <= 0; } + + /** + * 时间戳转 LocalDateTime (当天最小值) + * @param timestamp 时间戳 + * @return 当天最小值 + */ + public static LocalDateTime toLocalDateTimeMin(Long timestamp) { + LocalDateTime localDateTime = toLocalDateTime(timestamp); + if (Objects.isNull(localDateTime)) { + return null; + } + return localDateTime.with(LocalTime.MIN); + } + + /** + * 时间戳转 LocalDateTime (当天最大值) + * @param timestamp 时间戳 + * @return 当天最大值 + */ + public static LocalDateTime toLocalDateTimeMax(Long timestamp) { + LocalDateTime localDateTime = toLocalDateTime(timestamp); + if (Objects.isNull(localDateTime)) { + return null; + } + return localDateTime.with(LocalTime.MAX); + } + }