mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
DateUtil增加offsetYear方法
This commit is contained in:
@@ -1439,6 +1439,18 @@ public class DateUtil extends CalendarUtil {
|
||||
return offset(date, DateField.MONTH, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 偏移年
|
||||
*
|
||||
* @param date 日期
|
||||
* @param offset 偏移年数,正数向未来偏移,负数向历史偏移
|
||||
* @return 偏移后的日期
|
||||
* @since 5.8.29
|
||||
*/
|
||||
public static DateTime offsetYear(final Date date, final int offset) {
|
||||
return offset(date, DateField.YEAR, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定日期偏移指定时间后的时间,生成的偏移日期不影响原日期
|
||||
*
|
||||
|
Reference in New Issue
Block a user