This commit is contained in:
looly 2021-12-06 09:47:40 +08:00
parent e82c8c52c5
commit f12de13813
3 changed files with 30 additions and 14 deletions

View File

@ -45,6 +45,7 @@
* 【poi 】 修复CellUtil.setCellValuestyle空导致值无法写入问题issue#1995@Github
* 【poi 】 修复CellUtil.setComment参数设置错误问题
* 【core 】 修复QueryBuilder解析路径导致的错误issue#1989@Github
* 【core 】 修复DateTime.between中DateUnit无效问题
-------------------------------------------------------------------------------------------------------------

View File

@ -10,14 +10,17 @@ import java.util.Date;
* 日期间隔
*
* @author Looly
*
*/
public class DateBetween implements Serializable {
private static final long serialVersionUID = 1L;
/** 开始日期 */
/**
* 开始日期
*/
private final Date begin;
/** 结束日期 */
/**
* 结束日期
*/
private final Date end;
/**
@ -154,13 +157,25 @@ public class DateBetween implements Serializable{
}
/**
* 格式化输出时间差<br>
* 格式化输出时间差
*
* @param unit 日期单位
* @param level 级别
* @return 字符串
* @since 5.7.17
*/
public String toString(DateUnit unit, BetweenFormatter.Level level) {
return DateUtil.formatBetween(between(unit), level);
}
/**
* 格式化输出时间差
*
* @param level 级别
* @return 字符串
*/
public String toString(BetweenFormatter.Level level) {
return DateUtil.formatBetween(between(DateUnit.MS), level);
return toString(DateUnit.MS, level);
}
@Override

View File

@ -743,7 +743,7 @@ public class DateTime extends Date {
* @return 相差时长
*/
public String between(Date date, DateUnit unit, BetweenFormatter.Level formatLevel) {
return new DateBetween(this, date).toString(formatLevel);
return new DateBetween(this, date).toString(unit, formatLevel);
}
/**