The service code uses DateUtils to convert a long into a String format, which DateUtils converting the long to an instant, then an OffsetDateTime before passing this through a formatter, using the local timezone during the OffsetDateTime conversion.
As the test was using a pre-created String based on the UTC timezone, the test does not correctly compare the values when being executed in a different timezone. To overcome this, the test has been altered to use the same DateUtils methods to convert from the long to a String, thereby ensuring the same timezone handling is using in both test and live code.
The service code uses DateUtils to convert a long into a String format, which DateUtils converting the long to an instant, then an OffsetDateTime before passing this through a formatter, using the local timezone during the OffsetDateTime conversion. As the test was using a pre-created String based on the UTC timezone, the test does not correctly compare the values when being executed in a different timezone. To overcome this, the test has been altered to use the same DateUtils methods to convert from the long to a String, thereby ensuring the same timezone handling is using in both test and live code.