diff --git a/hutool-core/src/main/java/cn/hutool/core/date/Month.java b/hutool-core/src/main/java/cn/hutool/core/date/Month.java index cae70b500..fd3085fb2 100644 --- a/hutool-core/src/main/java/cn/hutool/core/date/Month.java +++ b/hutool-core/src/main/java/cn/hutool/core/date/Month.java @@ -108,11 +108,7 @@ public enum Month { * @return 此月份最后一天的值 */ public int getLastDay(boolean isLeapYear) { - int lastDay = DAYS_OF_MONTH[value]; - if (isLeapYear && Calendar.FEBRUARY == value){ - lastDay += 1; - } - return lastDay; + return getLastDay(this.value, isLeapYear); } /** @@ -166,4 +162,20 @@ public enum Month { return null; } } + + /** + * 获得指定月的最后一天 + * @param month 月份 + * @param isLeapYear 是否为闰年,闰年只对二月有影响 + * @return 最后一天,可能为28,29,30,31 + * @since 5.4.7 + */ + public static int getLastDay(int month, boolean isLeapYear){ + int lastDay = DAYS_OF_MONTH[month]; + if (isLeapYear && Calendar.FEBRUARY == month){ + // 二月 + lastDay += 1; + } + return lastDay; + } } diff --git a/hutool-cron/src/main/java/cn/hutool/cron/CronTimer.java b/hutool-cron/src/main/java/cn/hutool/cron/CronTimer.java index 84d7317a2..abc95544c 100644 --- a/hutool-cron/src/main/java/cn/hutool/cron/CronTimer.java +++ b/hutool-cron/src/main/java/cn/hutool/cron/CronTimer.java @@ -9,7 +9,7 @@ import java.io.Serializable; /** * 定时任务计时器
- * 计时器线程每隔一分钟检查一次任务列表,一旦匹配到执行对应的Task + * 计时器线程每隔一分钟(一秒钟)检查一次任务列表,一旦匹配到执行对应的Task * @author Looly * */ @@ -57,7 +57,7 @@ public class CronTimer extends Thread implements Serializable { spawnLauncher(thisTime); } } - log.debug("Hutool-cron timer stoped."); + log.debug("Hutool-cron timer stopped."); } /** diff --git a/hutool-cron/src/main/java/cn/hutool/cron/pattern/CronPattern.java b/hutool-cron/src/main/java/cn/hutool/cron/pattern/CronPattern.java index abb8da6d5..53ce2cb4b 100644 --- a/hutool-cron/src/main/java/cn/hutool/cron/pattern/CronPattern.java +++ b/hutool-cron/src/main/java/cn/hutool/cron/pattern/CronPattern.java @@ -111,8 +111,6 @@ public class CronPattern { /** * 构造 * - * @see CronPattern - * * @param pattern 表达式 */ public CronPattern(String pattern) { diff --git a/hutool-cron/src/main/java/cn/hutool/cron/pattern/matcher/BoolArrayValueMatcher.java b/hutool-cron/src/main/java/cn/hutool/cron/pattern/matcher/BoolArrayValueMatcher.java index 18d4bb721..a152f654f 100644 --- a/hutool-cron/src/main/java/cn/hutool/cron/pattern/matcher/BoolArrayValueMatcher.java +++ b/hutool-cron/src/main/java/cn/hutool/cron/pattern/matcher/BoolArrayValueMatcher.java @@ -1,10 +1,10 @@ package cn.hutool.cron.pattern.matcher; +import cn.hutool.core.util.StrUtil; + import java.util.Collections; import java.util.List; -import cn.hutool.core.util.StrUtil; - /** * 将表达式中的数字值列表转换为Boolean数组,匹配时匹配相应数组位 * @author Looly @@ -31,6 +31,6 @@ public class BoolArrayValueMatcher implements ValueMatcher{ @Override public String toString() { - return StrUtil.format("Matcher:{}", (Object)this.bValues); + return StrUtil.format("Matcher:{}", new Object[]{this.bValues}); } } diff --git a/hutool-cron/src/main/java/cn/hutool/cron/pattern/matcher/DayOfMonthValueMatcher.java b/hutool-cron/src/main/java/cn/hutool/cron/pattern/matcher/DayOfMonthValueMatcher.java index fd859a81f..75f1aec13 100644 --- a/hutool-cron/src/main/java/cn/hutool/cron/pattern/matcher/DayOfMonthValueMatcher.java +++ b/hutool-cron/src/main/java/cn/hutool/cron/pattern/matcher/DayOfMonthValueMatcher.java @@ -1,10 +1,12 @@ package cn.hutool.cron.pattern.matcher; +import cn.hutool.core.date.Month; + import java.util.List; /** * 每月第几天匹配
- * 考虑每月的天数不同,切存在闰年情况,日匹配单独使用 + * 考虑每月的天数不同,且存在闰年情况,日匹配单独使用 * * @author Looly * @@ -49,10 +51,6 @@ public class DayOfMonthValueMatcher extends BoolArrayValueMatcher { * @return 是否为本月最后一天 */ private static boolean isLastDayOfMonth(int value, int month, boolean isLeapYear) { - if (isLeapYear && month == 2) { - return value == 29; - } else { - return value == LAST_DAYS[month - 1]; - } + return value == Month.getLastDay(month, isLeapYear); } } diff --git a/hutool-http/src/test/java/cn/hutool/http/server/SimpleServerTest.java b/hutool-http/src/test/java/cn/hutool/http/server/SimpleServerTest.java index 633943dc7..bca649874 100644 --- a/hutool-http/src/test/java/cn/hutool/http/server/SimpleServerTest.java +++ b/hutool-http/src/test/java/cn/hutool/http/server/SimpleServerTest.java @@ -5,6 +5,7 @@ import cn.hutool.core.lang.Console; import cn.hutool.core.net.multipart.UploadFile; import cn.hutool.http.ContentType; import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; public class SimpleServerTest { @@ -17,9 +18,13 @@ public class SimpleServerTest { response.write(request.getURI().toString(), ContentType.TEXT_PLAIN.toString()) ) // 返回JSON数据测试 - .addAction("/restTest", (request, response) -> - response.write("{\"id\": 1, \"msg\": \"OK\"}", ContentType.JSON.toString()) - ) + .addAction("/restTest", (request, response) -> { + String res = JSONUtil.createObj() + .set("id", 1) + .set("method", request.getMethod()) + .toStringPretty(); + response.write(res, ContentType.JSON.toString()); + }) // 获取表单数据测试 // http://localhost:8888/formTest?a=1&a=2&b=3 .addAction("/formTest", (request, response) -> diff --git a/hutool-http/src/test/java/cn/hutool/http/test/RestTest.java b/hutool-http/src/test/java/cn/hutool/http/test/RestTest.java index 2730ec6d9..4a43c05c6 100644 --- a/hutool-http/src/test/java/cn/hutool/http/test/RestTest.java +++ b/hutool-http/src/test/java/cn/hutool/http/test/RestTest.java @@ -1,6 +1,7 @@ package cn.hutool.http.test; import cn.hutool.core.lang.Console; +import cn.hutool.http.Header; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONUtil; @@ -46,8 +47,9 @@ public class RestTest { @Test @Ignore - public void postTest3() { - HttpRequest request = HttpRequest.post("http://211.162.39.204:8181/jeesite-simple/a/open/bizGwbnService/test")// + public void getWithBodyTest() { + HttpRequest request = HttpRequest.get("http://localhost:8888/restTest")// + .header(Header.CONTENT_TYPE, "application/json") .body(JSONUtil.createObj() .set("aaa", "aaaValue") .set("键2", "值2").toString()); diff --git a/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelWriter.java b/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelWriter.java index 6d9137134..b484bfa69 100644 --- a/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelWriter.java +++ b/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelWriter.java @@ -965,7 +965,7 @@ public class ExcelWriter extends ExcelBase { * @param y Y坐标,从0计数,即行号 * @return {@link CellStyle} * @since 4.0.9 - * @deprecated 请使用{@link #createCellStyle(int, int)} + * @deprecated 请使用 {@link #createCellStyle(int, int)} */ @Deprecated public CellStyle createStyleForCell(int x, int y) {