0

I need to validate the date & timestamp being displayed in a json response to results from jdbc connection to the database. The date & timestamps are taken from the database, manipulated and displayed in UTC format in the JSON response. How can I establish this validation using groovy?

Dates:

   JSON - formats:
       1999-12-31T05:00:00.000Z
       2016-09-20T04:00:00.000Z

Is this the SimpleDateFormat pattern to be used -"yyyy-MM-dd'T'HH:mm:ss.SSSZ"? The time section of this date will either always be 05:00:00.000Z or 04:00:00.000Z regardless of what is in the db.

   JDBC - formats:
        1999-12-31 00:00:00
        2016-09-20 09:23:53.139537
        2016-09-20 09:27:13.96773

Timestamps:

   JSON - formats:
        2016-09-20 09:23:53.139537
        2016-09-20 09:27:13.96773
        2016-09-19 09:49:20.0

Is this the SimpleDateFormat pattern to be used - "yyyy-MM-dd hh:mm:ss.SSSSSS"? How to deal with the missing trailing zeroes ('0')?

   JDBC - formats:
        2016-09-20 09:23:53.139537
        2016-09-20 09:27:13.96773
        2016-09-19 09:49:20

How to deal with the missing trailing zeroes ('0')?

How can I go about with this solution? Any guidance will be much appreciated. Thanks!

ssc
  • 35
  • 2
  • 9
  • what validation you are trying to establish? Do you only want to compare thses dates or anything else? – Abhinandan Satpute Sep 27 '16 at 16:30
  • @AbhinandanSatpute Yes, I would like to use `assert` on them to compare and validate that the dates represented in the `JSON` response are in fact the same dates from the database but in the correct format for `UTC`. UTC formats can be seen in the `JSON - formats` above. – ssc Sep 27 '16 at 16:34
  • 1
    Java 8? http://stackoverflow.com/questions/30090710/java-8-datetimeformatter-parsing-for-optional-fractional-seconds-of-varying-sign – tim_yates Sep 27 '16 at 16:35
  • @tim_yates Will try in Groovy... this could help. Thanks! – ssc Sep 27 '16 at 16:43

0 Answers0