4

我需要一个日期格式

2011 年 5 月 31 日星期二 17:46:55 +0800

我正在使用的当前格式是

implicit val formats = Serialization.formats(NoTypeHints)

它将产生:

2011-05-31 17:46:55.0

如何制作产生类似字符串的格式 "Tue May 31 17:46:55 +0800 2011"

4

1 回答 1

3
private def formatsWithDate(customDateFormat : SimpleDateFormat): Formats = {
    new DefaultFormats {
      override val dateFormatter = customDateFormat
    }
  }

通过这种方式,您可以设置自己的日期格式

注意:对于 3.2.9 之前的版本,json4s 将使用 UTC 时区,无论您在 dateformat 中设置什么时区

于 2013-10-12T04:34:13.517 回答