Domanda

I need a date format like

Tue May 31 17:46:55 +0800 2011

And the current formats I am using is

implicit val formats = Serialization.formats(NoTypeHints)

It will produce :

2011-05-31 17:46:55.0

How can I make the formats that produce string like "Tue May 31 17:46:55 +0800 2011" ?

È stato utile?

Soluzione

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

By this way you can set your own date format

Caution: for version earlier than 3.2.9, json4s will use UTC timezone, regardless of what timezone you set in the dateformat

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top