title: How to match dates through fromJson(toJson(date)) with specs2
body: <p>I am stuck on the following problem : I want to write a specs2 specification to assert that my to and from json transformations are symetrical. However, I get an error on joda datetime dates.</p>
  
  <pre><code>'2012-04-17T00:04:00.000+02:00' is not equal to '2012-04-17T00:04:00.000+02:00'. Values have the same string representation but possibly different types like List[Int] and List[String] (TimeSpecs.scala:18) 
  </code></pre>
  
  <p>Here is a minimalist specs demonstrating the problem</p>
  
  <pre><code>import org.joda.time.DateTime
  import org.specs2.mutable.Specification
  
  class TimeSpecs extends Specification {
    "joda and specs2" should {
      "play nice" in {
        val date = DateTime.parse("2012-04-17T00:04:00+0200")
        val date2 = DateTime.parse("2012-04-17T00:04:00+0200")
        date === date2
      }
      "play nice through play json transform" in {
        import play.api.libs.json._
        import play.api.libs.json.Json._
        val date = DateTime.parse("2012-04-17T00:04:00+0200")
        val jsDate= toJson(date)
        val date2= jsDate.as[DateTime]
  
        date === date2
      }
    }
  }
  </code></pre>
  
  <p>how should I compare date and date2 in the second test ? they are the same but specs2 doesn't seem to see that :(</p>
  
  <p>--- edit</p>
  
  <p>"manually" inspecting the type at runtime with date.getClass.getCanonicalName returns org.joda.time.Datetime as expected</p>
  
  <pre><code>import org.joda.time.DateTime
  import org.specs2.mutable.Specification
  
  class TimeSpecs extends Specification {
    "joda and specs2" should {
      "play nice" in {
        val date = DateTime.parse("2012-04-17T00:04:00+0200")
        val date2 = DateTime.parse("2012-04-17T00:04:00+0200")
        date === date2
      }
      "play nice through play json transform" in {
        import play.api.libs.json._
        import play.api.libs.json.Json._
        val date:DateTime = DateTime.parse("2012-04-17T00:04:00+0200")
        val jsDate= toJson(date)
        val date2:DateTim= jsDate.as[DateTime]
        println(date.getClass.getCanonicalName) //prints org.joda.time.DateTime
        println(date2.getClass.getCanonicalName)//prints org.joda.time.DateTime
        date === date2
      }
    }
  }
  </code></pre>
  
  <p>Using DateTime#isEqual does kind of work but I loose the benefit of fluent matchers and the useful error messages they bring. Aditionally, what I am actually trying to compare are case class instances which happen to contain dates, not the dates themselves. </p>
  
  <p>Using </p>
  
  <pre><code>      date should beEqualTo(date2)
  </code></pre>
  
  <p>yields the same error as <code>===</code></p>