title: How to handle EPOCH data with lift-json
body: <p>I'm using lift-json (lift 2.6-M3) and
  trying to handle json data which has epoch values like</p>
  
  <pre><code>"updatetime": 1249409679,
  </code></pre>
  
  <p>Of course lift-json can treat them as JInt values and extract objects as Long fields,
  but is there a way to treat them as Date (or DateTime etc) objects?</p>
  
  <p>Added 5/16/2014:
  The following code seems to work.</p>
  
  <pre><code>implicit val formats = DefaultFormats + new Serializer[java.util.Date] {
      def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), java.util.Date] = {
          case (t, JInt(num)) if (t.clazz == classOf[java.util.Date]) =&gt; new java.util.Date(num.toLong * 1000)
      }
      def serialize(implicit format: Formats): PartialFunction[Any, JValue] = {
          case x if (x.getClass == classOf[java.util.Date]) =&gt; new JInt(x.asInstanceOf[java.util.Date].getTime / 1000)
      }
  }
  </code></pre>