mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
LocalDateTimeUtil增加beginOfDay和endOfDay重载
This commit is contained in:
parent
1fc4148021
commit
2f1583a931
@ -24,6 +24,7 @@
|
||||
* 【core 】 ListUtil.setOrPadding增加重载,可选限制index大小(issue#3586@Github)
|
||||
* 【http 】 getFileNameFromDisposition更加规范,从多个头的值中获取,且`filename*`优先级更高(pr#3590@Gitee)
|
||||
* 【core 】 CsvWriter增加重载writeBeans方法,支持可选bean字段(pr#1222@Gitee)
|
||||
* 【core 】 LocalDateTimeUtil增加beginOfDay和endOfDay重载(issue#3594@Github)
|
||||
|
||||
### 🐞Bug修复
|
||||
* 【http 】 修复HttpUtil.urlWithFormUrlEncoded方法重复编码问题(issue#3536@Github)
|
||||
|
@ -478,6 +478,17 @@ public class LocalDateTimeUtil {
|
||||
return time.with(LocalTime.MIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改为一天的开始时间,例如:2020-02-02 00:00:00,000
|
||||
*
|
||||
* @param date 日期时间
|
||||
* @return 一天的开始时间
|
||||
* @since 5.8.28
|
||||
*/
|
||||
public static LocalDateTime beginOfDay(LocalDate date) {
|
||||
return LocalDateTime.of(date, LocalTime.MIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改为一天的结束时间,例如:2020-02-02 23:59:59,999
|
||||
*
|
||||
@ -488,6 +499,17 @@ public class LocalDateTimeUtil {
|
||||
return endOfDay(time, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改为一天的结束时间,例如:2020-02-02 23:59:59,999
|
||||
*
|
||||
* @param date 日期时间
|
||||
* @return 一天的结束时间
|
||||
* @since 5.8.28
|
||||
*/
|
||||
public static LocalDateTime endOfDay(LocalDate date) {
|
||||
return endOfDay(date, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改为一天的结束时间,例如:
|
||||
* <ul>
|
||||
@ -507,6 +529,25 @@ public class LocalDateTimeUtil {
|
||||
return time.with(LocalTime.MAX);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改为一天的结束时间,例如:
|
||||
* <ul>
|
||||
* <li>毫秒不归零:2020-02-02 23:59:59,999</li>
|
||||
* <li>毫秒归零:2020-02-02 23:59:59,000</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param date 日期时间
|
||||
* @param truncateMillisecond 是否毫秒归零
|
||||
* @return 一天的结束时间
|
||||
* @since 5.7.18
|
||||
*/
|
||||
public static LocalDateTime endOfDay(LocalDate date, boolean truncateMillisecond) {
|
||||
if (truncateMillisecond) {
|
||||
return LocalDateTime.of(date, LocalTime.of(23, 59, 59));
|
||||
}
|
||||
return LocalDateTime.of(date, LocalTime.MAX);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link TemporalAccessor}转换为 时间戳(从1970-01-01T00:00:00Z开始的毫秒数)
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user