mirror of
https://gitee.com/dromara/hutool.git
synced 2026-02-09 09:16:26 +08:00
fix cron bug
This commit is contained in:
@@ -797,6 +797,28 @@ public class CalendarUtil {
|
||||
}
|
||||
// endregion
|
||||
|
||||
/**
|
||||
* 是否为本月第一天
|
||||
*
|
||||
* @param calendar {@link Calendar}
|
||||
* @return 是否为本月最后一天
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public static boolean isFirstDayOfMonth(final Calendar calendar) {
|
||||
return 1 == calendar.get(Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为本月最后一天
|
||||
*
|
||||
* @param calendar {@link Calendar}
|
||||
* @return 是否为本月最后一天
|
||||
* @since 5.8.27
|
||||
*/
|
||||
public static boolean isLastDayOfMonth(final Calendar calendar) {
|
||||
return calendar.get(Calendar.DAY_OF_MONTH) == calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算相对于dateToCompare的年龄(周岁),常用于计算指定生日在某年的年龄<br>
|
||||
* 按照《最高人民法院关于审理未成年人刑事案件具体应用法律若干问题的解释》第二条规定刑法第十七条规定的“周岁”,按照公历的年、月、日计算,从周岁生日的第二天起算。
|
||||
@@ -844,26 +866,4 @@ public class CalendarUtil {
|
||||
|
||||
return age;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为本月第一天
|
||||
*
|
||||
* @param calendar {@link Calendar}
|
||||
* @return 是否为本月最后一天
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public static boolean isFirstDayOfMonth(final Calendar calendar) {
|
||||
return 1 == calendar.get(Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为本月最后一天
|
||||
*
|
||||
* @param calendar {@link Calendar}
|
||||
* @return 是否为本月最后一天
|
||||
* @since 5.8.27
|
||||
*/
|
||||
public static boolean isLastDayOfMonth(final Calendar calendar) {
|
||||
return calendar.get(Calendar.DAY_OF_MONTH) == calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import cn.hutool.v7.core.lang.Assert;
|
||||
import cn.hutool.v7.core.text.StrUtil;
|
||||
import cn.hutool.v7.core.util.ObjUtil;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
@@ -51,6 +52,7 @@ import java.util.TimeZone;
|
||||
* @author Looly
|
||||
*/
|
||||
public class DateTime extends Date {
|
||||
@Serial
|
||||
private static final long serialVersionUID = -5395712593979185936L;
|
||||
|
||||
private static boolean useJdkToStringStyle = false;
|
||||
|
||||
@@ -1985,22 +1985,15 @@ public class DateUtil {
|
||||
* @since 5.7.16
|
||||
*/
|
||||
public static String getShortName(final TimeUnit unit) {
|
||||
switch (unit) {
|
||||
case NANOSECONDS:
|
||||
return "ns";
|
||||
case MICROSECONDS:
|
||||
return "μs";
|
||||
case MILLISECONDS:
|
||||
return "ms";
|
||||
case SECONDS:
|
||||
return "s";
|
||||
case MINUTES:
|
||||
return "min";
|
||||
case HOURS:
|
||||
return "h";
|
||||
default:
|
||||
return unit.name().toLowerCase();
|
||||
}
|
||||
return switch (unit) {
|
||||
case NANOSECONDS -> "ns";
|
||||
case MICROSECONDS -> "μs";
|
||||
case MILLISECONDS -> "ms";
|
||||
case SECONDS -> "s";
|
||||
case MINUTES -> "min";
|
||||
case HOURS -> "h";
|
||||
default -> unit.name().toLowerCase();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user