'SonarLint: Invoke method(s) only conditionally on ZonedDateTime.now().format

The ZonedDateTime.now().format(dateformat) in below code is causing SonarLint warning

Invoke method(s) only conditionally.

logger.info("{} : Return Code: {}", ZonedDateTime.now().format(dateformat), HttpStatus.OK);

what is the better way to do this so as not to cause this warning?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source