change name to DateFormatManager

This commit is contained in:
Looly
2024-10-11 09:07:24 +08:00
parent ae1f3635ce
commit 03681f3d40
12 changed files with 116 additions and 69 deletions

View File

@@ -22,7 +22,7 @@ import org.dromara.hutool.core.annotation.PropIgnore;
import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.date.DateFormatPool;
import org.dromara.hutool.core.date.DateUtil;
import org.dromara.hutool.core.date.format.GlobalCustomFormat;
import org.dromara.hutool.core.date.format.DateFormatManager;
import org.dromara.hutool.core.io.resource.ResourceUtil;
import org.dromara.hutool.core.map.MapUtil;
import org.dromara.hutool.core.text.StrUtil;
@@ -491,7 +491,7 @@ public class JSONObjectTest {
@Test
public void setDateFormatSecondsTest() {
// 自定义格式为只有秒的时间戳一般用于JWT
final JSONConfig jsonConfig = JSONConfig.of().setDateFormat(GlobalCustomFormat.FORMAT_SECONDS);
final JSONConfig jsonConfig = JSONConfig.of().setDateFormat(DateFormatManager.FORMAT_SECONDS);
final Date date = DateUtil.parse("2020-06-05 11:16:11");
final JSONObject json = new JSONObject(jsonConfig);
@@ -507,7 +507,7 @@ public class JSONObjectTest {
@Test
public void setCustomDateFormatTest() {
final JSONConfig jsonConfig = JSONConfig.of();
jsonConfig.setDateFormat(GlobalCustomFormat.FORMAT_SECONDS);
jsonConfig.setDateFormat(DateFormatManager.FORMAT_SECONDS);
final Date date = DateUtil.parse("2020-06-05 11:16:11");
final JSONObject json = new JSONObject(jsonConfig);

View File

@@ -19,7 +19,7 @@ package org.dromara.hutool.json.jwt;
import lombok.Data;
import org.dromara.hutool.core.date.DateUtil;
import org.dromara.hutool.core.date.TimeUtil;
import org.dromara.hutool.core.date.format.GlobalCustomFormat;
import org.dromara.hutool.core.date.format.DateFormatManager;
import org.dromara.hutool.json.JSONConfig;
import org.dromara.hutool.json.JSONObject;
import org.dromara.hutool.json.JSONUtil;
@@ -41,7 +41,7 @@ public class IssueI6IS5BTest {
final JwtToken jwtToken = new JwtToken();
jwtToken.setIat(iat);
final JSONObject payloadsData = JSONUtil.parseObj(jwtToken, JSONConfig.of().setDateFormat(GlobalCustomFormat.FORMAT_SECONDS));
final JSONObject payloadsData = JSONUtil.parseObj(jwtToken, JSONConfig.of().setDateFormat(DateFormatManager.FORMAT_SECONDS));
final String token = JWTUtil.createToken(payloadsData, "123".getBytes(StandardCharsets.UTF_8));
Assertions.assertEquals("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2Nzc3NzI4MDB9.SXU_mm1wT5lNoK-Dq5Y8f3BItv_44zuAlyeWLqajpXg", token);
@@ -62,7 +62,7 @@ public class IssueI6IS5BTest {
final JwtToken2 jwtToken = new JwtToken2();
jwtToken.setIat(iat);
final JSONObject payloadsData = JSONUtil.parseObj(jwtToken, JSONConfig.of().setDateFormat(GlobalCustomFormat.FORMAT_SECONDS));
final JSONObject payloadsData = JSONUtil.parseObj(jwtToken, JSONConfig.of().setDateFormat(DateFormatManager.FORMAT_SECONDS));
final String token = JWTUtil.createToken(payloadsData, "123".getBytes(StandardCharsets.UTF_8));
Assertions.assertEquals("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2Nzc3NzI4MDB9.SXU_mm1wT5lNoK-Dq5Y8f3BItv_44zuAlyeWLqajpXg", token);