mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
DateUtil增加isLastDayOfMonth、getLastDayOfMonth方法
This commit is contained in:
parent
c4133dd981
commit
9ffe5d67f5
@ -6,6 +6,8 @@
|
|||||||
# 5.8.9.M1 (2022-09-30)
|
# 5.8.9.M1 (2022-09-30)
|
||||||
|
|
||||||
### 🐣新特性
|
### 🐣新特性
|
||||||
|
* 【core 】 DateUtil增加isLastDayOfMonth、getLastDayOfMonth方法(pr#824@Gitee)
|
||||||
|
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【poi 】 修复ExcelReader读取只有标题行报错问题(issue#I5U1JA@Gitee)
|
* 【poi 】 修复ExcelReader读取只有标题行报错问题(issue#I5U1JA@Gitee)
|
||||||
* 【http 】 修复Http重定向时相对路径导致的问题(issue#I5TPSY@Gitee)
|
* 【http 】 修复Http重定向时相对路径导致的问题(issue#I5TPSY@Gitee)
|
||||||
|
@ -946,6 +946,24 @@ public class DateTime extends Date {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为本月最后一天
|
||||||
|
* @return 是否为本月最后一天
|
||||||
|
* @since 5.8.9
|
||||||
|
*/
|
||||||
|
public boolean isLastDayOfMonth(){
|
||||||
|
return dayOfMonth() == getLastDayOfMonth();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得本月的最后一天
|
||||||
|
* @return 天
|
||||||
|
* @since 5.8.9
|
||||||
|
*/
|
||||||
|
public int getLastDayOfMonth(){
|
||||||
|
return monthEnum().getLastDay(isLeapYear());
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------- toString start
|
// -------------------------------------------------------------------- toString start
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2249,22 +2249,22 @@ public class DateUtil extends CalendarUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为本月最后一天
|
* 是否为本月最后一天
|
||||||
* @param dateTime {@link DateTime}
|
* @param date {@link Date}
|
||||||
* @return 是否为本月最后一天
|
* @return 是否为本月最后一天
|
||||||
* @since 5.8.8
|
* @since 5.8.9
|
||||||
*/
|
*/
|
||||||
public static boolean isLastDayOfMonth(DateTime dateTime){
|
public static boolean isLastDayOfMonth(Date date){
|
||||||
return dateTime.dayOfMonth()==getLastDayOfMonth(dateTime);
|
return date(date).isLastDayOfMonth();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得本月的最后一天
|
* 获得本月的最后一天
|
||||||
* @param dateTime {@link DateTime}
|
* @param date {@link Date}
|
||||||
* @return 天
|
* @return 天
|
||||||
* @since 5.8.8
|
* @since 5.8.9
|
||||||
*/
|
*/
|
||||||
public static int getLastDayOfMonth(DateTime dateTime){
|
public static int getLastDayOfMonth(Date date){
|
||||||
return Month.getLastDay(dateTime.month(),dateTime.isLeapYear());
|
return date(date).getLastDayOfMonth();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------ Private method start
|
// ------------------------------------------------------------------------ Private method start
|
||||||
|
Loading…
Reference in New Issue
Block a user