I've tests where I've to check whether current time and current date/time is correctly returned by my APIs through automation.
getCurrentTime() returns current time in format
HH:MM:SS (A/P)M and
getCurrentDateTime() returns current date/time in format
DD/MM?YYYY HH:MM:SS (A/P)M
In automation, I'm storing current time like -
actualCurrentTime=getCurrentTime() suppose this returns
and after above call, I make java API call to get expectedCurrentTime and it'll return with differences of one or two seconds like
Now, if I add assertion
This will fail because time is differing with few seconds. This is also true for current date/time because it contains time part.
I'm confused how to automate this or what approach should be used to automate this.