|
|
@ -262,7 +262,7 @@ public class JSONUtilsTest { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void dateToString() { |
|
|
|
public void dateToString() { |
|
|
|
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); |
|
|
|
TimeZone.setDefault(TimeZone.getTimeZone("UTC")); |
|
|
|
String time = "2022-02-22 13:38:24"; |
|
|
|
String time = "2022-02-22 13:38:24"; |
|
|
|
Date date = DateUtils.stringToDate(time); |
|
|
|
Date date = DateUtils.stringToDate(time); |
|
|
|
String json = JSONUtils.toJsonString(date); |
|
|
|
String json = JSONUtils.toJsonString(date); |
|
|
@ -274,7 +274,7 @@ public class JSONUtilsTest { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void stringToDate() { |
|
|
|
public void stringToDate() { |
|
|
|
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); |
|
|
|
TimeZone.setDefault(TimeZone.getTimeZone("UTC")); |
|
|
|
String json = "\"2022-02-22 13:38:24\""; |
|
|
|
String json = "\"2022-02-22 13:38:24\""; |
|
|
|
Date date = JSONUtils.parseObject(json, Date.class); |
|
|
|
Date date = JSONUtils.parseObject(json, Date.class); |
|
|
|
Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); |
|
|
|
Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); |
|
|
|