I have written some class encode decode routines to json and back. This works except for one explicit type which is Date
without showing the complete library, here is my problem
Date now = Date.newInstance()
println "now : $now"
Date reconverted = new SimpleDateFormat('EEE MMM dd HH:mm:ss Z yyyy').parse(now.toString())
println "reconverted : $reconverted"
assert reconverted == now //this assertion fails
if you look at the output string text for both they are the same. But the 'reconverted' object is not equal to the 'now' object.
Is this due to lost precision somewhere in Date? I had assumed that the reconstructed value would be equal.
This is just a problem as i cannot assert that my encoded/decoded class instance are the same, if the class has Date fields
I don't have this problem with LocalDateTime encode/decode where my decode parse looks like this
LocalDateTime.parse (jsonStrValue)
when when i check for equivalence works just fine
What am i missing for Date that stops this working ?