mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-12-06 17:18:54 +08:00
add test
This commit is contained in:
parent
aa488485cc
commit
e9a615691c
@ -0,0 +1,22 @@
|
|||||||
|
package cn.hutool.json.xml;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.json.JSONConfig;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class IssueID0HP2Test {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON转换为XML时使用默认的日期格式,并不能自定义格式,日期格式只用于生成JSON字符串
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void jsonWithDateToXmlTest() {
|
||||||
|
final JSONObject json = JSONUtil.createObj(JSONConfig.create().setDateFormat("yyyy/MM/dd"))
|
||||||
|
.set("date", DateUtil.parse("2025-10-03"));
|
||||||
|
String xml = JSONUtil.toXmlStr(json);
|
||||||
|
Assertions.assertEquals("<date>2025-10-03 00:00:00</date>", xml);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user