Skip to content

Commit

Permalink
新增可根据时间戳获取当天最大或最小的方法
Browse files Browse the repository at this point in the history
  • Loading branch information
fengwenyi committed Apr 10, 2023
1 parent 5f05491 commit 31d15a4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

## v2.2.5

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



## v2.2.4
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/com/fengwenyi/javalib/convert/DateTimeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}

0 comments on commit 31d15a4

Please sign in to comment.