mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
add method
This commit is contained in:
parent
232c292dfc
commit
01ac41f08e
@ -8,6 +8,7 @@
|
||||
### 新特性
|
||||
* 【socket】 对NioServer和NioClient改造(pr#992@Github)
|
||||
* 【core 】 StrUtil增加filter方法(pr#149@Gitee)
|
||||
* 【core 】 DateUtil增加beginOfWeek重载
|
||||
|
||||
### Bug修复#
|
||||
|
||||
|
@ -1041,6 +1041,18 @@ public class DateUtil extends CalendarUtil {
|
||||
return new DateTime(beginOfWeek(calendar(date)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某周的开始时间
|
||||
*
|
||||
* @param date 日期
|
||||
* @param isMondayAsFirstDay 是否周一做为一周的第一天(false表示周日做为第一天)
|
||||
* @return {@link DateTime}
|
||||
* @since 5.4.0
|
||||
*/
|
||||
public static DateTime beginOfWeek(Date date, boolean isMondayAsFirstDay) {
|
||||
return new DateTime(beginOfWeek(calendar(date), isMondayAsFirstDay));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某周的结束时间,周日定为一周的结束
|
||||
*
|
||||
@ -1051,6 +1063,18 @@ public class DateUtil extends CalendarUtil {
|
||||
return new DateTime(endOfWeek(calendar(date)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某周的结束时间
|
||||
*
|
||||
* @param date 日期
|
||||
* @param isSundayAsLastDay 是否周日做为一周的最后一天(false表示周六做为最后一天)
|
||||
* @return {@link DateTime}
|
||||
* @since 5.4.0
|
||||
*/
|
||||
public static DateTime endOfWeek(Date date, boolean isSundayAsLastDay) {
|
||||
return new DateTime(endOfWeek(calendar(date), isSundayAsLastDay));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某月的开始时间
|
||||
*
|
||||
|
@ -99,7 +99,7 @@ public class DateUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beginAndWeedTest() {
|
||||
public void beginOfWeekTest() {
|
||||
String dateStr = "2017-03-01 22:33:23";
|
||||
DateTime date = DateUtil.parse(dateStr);
|
||||
Objects.requireNonNull(date).setFirstDayOfWeek(Week.MONDAY);
|
||||
@ -121,7 +121,7 @@ public class DateUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beginAndWeedTest2() {
|
||||
public void beginOfWeekTest2() {
|
||||
String beginStr = "2020-03-11";
|
||||
DateTime date = DateUtil.parseDate(beginStr);
|
||||
Calendar calendar = date.toCalendar();
|
||||
|
Loading…
Reference in New Issue
Block a user