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!