add method

This commit is contained in:
looly 2021-12-06 09:54:19 +08:00
parent f12de13813
commit b7663ff7e7

View File

@ -44,6 +44,11 @@ public class DateTime extends Date {
*/ */
private TimeZone timeZone; private TimeZone timeZone;
/**
* 第一周最少天数
*/
private int minimalDaysInFirstWeek;
/** /**
* 转换时间戳为 DateTime * 转换时间戳为 DateTime
* *
@ -670,6 +675,10 @@ public class DateTime extends Date {
final Calendar cal = (null != zone) ? Calendar.getInstance(zone, locale) : Calendar.getInstance(locale); final Calendar cal = (null != zone) ? Calendar.getInstance(zone, locale) : Calendar.getInstance(locale);
//noinspection MagicConstant //noinspection MagicConstant
cal.setFirstDayOfWeek(firstDayOfWeek.getValue()); cal.setFirstDayOfWeek(firstDayOfWeek.getValue());
// issue#1988@Github
if (minimalDaysInFirstWeek > 0) {
cal.setMinimalDaysInFirstWeek(minimalDaysInFirstWeek);
}
cal.setTime(this); cal.setTime(this);
return cal; return cal;
} }
@ -908,6 +917,18 @@ public class DateTime extends Date {
return this; return this;
} }
/**
* 设置第一周最少天数
*
* @param minimalDaysInFirstWeek 第一周最少天数
* @return this
* @since 5.7.17
*/
public DateTime setMinimalDaysInFirstWeek(int minimalDaysInFirstWeek) {
this.minimalDaysInFirstWeek = minimalDaysInFirstWeek;
return this;
}
// -------------------------------------------------------------------- toString start // -------------------------------------------------------------------- toString start
/** /**