我需要一个日期格式
Tue May 31 17:46:55 +0800 2011
我使用的当前格式是
implicit val formats = Serialization.formats(NoTypeHints)
它将产生:
2011-05-31 17:46:55.0
如何制作生成字符串的格式,如
"Tue May 31 17:46:55 +0800 2011"
?
最佳答案
private def formatsWithDate(customDateFormat : SimpleDateFormat): Formats = {
new DefaultFormats {
override val dateFormatter = customDateFormat
}
}
通过这种方式,您可以设置自己的日期格式
Caution: for version earlier than 3.2.9, json4s will use UTC timezone, regardless of what timezone you set in the dateformat
关于scala -- 如何使用 json4s 使用 SimpleDateFormat 自定义日期格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19330564/