Skip to content

Commit 31d15a4

Browse files
committed
新增可根据时间戳获取当天最大或最小的方法
1 parent 5f05491 commit 31d15a4

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

LOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
## v2.2.5
1212

13+
- DateTimeUtils 新增可根据时间戳获取当天最大或最小的方法
14+
1315

1416

1517
## v2.2.4

src/main/java/com/fengwenyi/javalib/convert/DateTimeUtils.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,4 +408,31 @@ public static boolean judgeInTimeDurationWithBoundary(LocalTime time, LocalTime
408408
return time.compareTo(startTime) >= 0 || time.compareTo(endTime) <= 0;
409409
}
410410

411+
412+
/**
413+
* 时间戳转 LocalDateTime (当天最小值)
414+
* @param timestamp 时间戳
415+
* @return 当天最小值
416+
*/
417+
public static LocalDateTime toLocalDateTimeMin(Long timestamp) {
418+
LocalDateTime localDateTime = toLocalDateTime(timestamp);
419+
if (Objects.isNull(localDateTime)) {
420+
return null;
421+
}
422+
return localDateTime.with(LocalTime.MIN);
423+
}
424+
425+
/**
426+
* 时间戳转 LocalDateTime (当天最大值)
427+
* @param timestamp 时间戳
428+
* @return 当天最大值
429+
*/
430+
public static LocalDateTime toLocalDateTimeMax(Long timestamp) {
431+
LocalDateTime localDateTime = toLocalDateTime(timestamp);
432+
if (Objects.isNull(localDateTime)) {
433+
return null;
434+
}
435+
return localDateTime.with(LocalTime.MAX);
436+
}
437+
411438
}

0 commit comments

Comments
 (0)