We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在设置JSON.configWriterDateFormat("yyyy-MM-dd HH:mm:ss");后,仍然需要进行对context的设置,否则timestamp序列化时,会输出整数串
全局设置好日期格式后,应该不需要再设置context
无
The text was updated successfully, but these errors were encountered:
add testcase for issue #2426
bfa24a7
@Test public void test() { String defaultWriterFormat = JSONFactory.getDefaultWriterFormat(); try { String dateFormat = "yyyy-MM-dd'T'HH:mm:ss"; JSON.configWriterDateFormat(dateFormat); JSONWriter.Context writeContext = JSONFactory.createWriteContext(); assertEquals(dateFormat, writeContext.getDateFormat()); Date date = new Date(1712988987882L); String json = JSON.toJSONString(date, writeContext); assertEquals("\"2024-04-13T14:16:27\"", json); java.sql.Timestamp ts = new Timestamp(date.getTime()); String json1 = JSON.toJSONString(date, writeContext); assertEquals("\"2024-04-13T14:16:27\"", json1); } finally { JSON.configWriterDateFormat(defaultWriterFormat); } assertEquals(defaultWriterFormat, JSONFactory.getDefaultWriterFormat()); }
设置过全局的dateFormat之后不需要额外设置,不过你要注意构造Context和设置全局dateFormat的先后顺序
Sorry, something went wrong.
bc167b0
No branches or pull requests
请描述您的需求或者改进建议
在设置JSON.configWriterDateFormat("yyyy-MM-dd HH:mm:ss");后,仍然需要进行对context的设置,否则timestamp序列化时,会输出整数串
请描述你建议的实现方案
全局设置好日期格式后,应该不需要再设置context
描述您考虑过的替代方案
无
附加信息
无
The text was updated successfully, but these errors were encountered: