This commit is contained in:
Looly
2025-10-03 20:26:53 +08:00
parent 73de40813f
commit 8ef76cc56b

View File

@@ -9,12 +9,14 @@ import org.junit.jupiter.api.Test;
public class IssueID0HP2Test {
/**
* JSON转换为XML时使用自定义格式
* JSON转换为XML时使用自定义格式<br>
* putValue时就会把日期转为自定义格式的字符串因此转XML是直接转换
*/
@Test
void jsonWithDateToXmlTest() {
final JSONObject json = JSONUtil.ofObj(JSONConfig.of().setDateFormat("yyyy/MM/dd"))
.putValue("date", DateUtil.parse("2025-10-03"));
String xml = JSONUtil.toXmlStr(json);
Assertions.assertEquals("<date>2025/10/03</date>", xml);
}