DateUtil增加offsetYear方法

This commit is contained in:
Looly 2024-05-29 15:06:13 +08:00
parent 245d8c5e95
commit 0d0727d0f9

View File

@ -1197,6 +1197,17 @@ public class DateUtil extends CalendarUtil {
return offset(date, DateField.MONTH, offset);
}
/**
* 偏移年
*
* @param date 日期
* @param offset 偏移年数正数向未来偏移负数向历史偏移
* @return 偏移后的日期
*/
public static DateTime offsetYear(final Date date, final int offset) {
return offset(date, DateField.YEAR, offset);
}
/**
* 获取指定日期偏移指定时间后的时间生成的偏移日期不影响原日期
*