Patheek Chokshi
Patheek Chokshi

Reputation: 121

Springboot 2.1 Actuator /info shows build and git time as timestamp

I have included build info and git info file in my jar file. So, calling springboot actuator's /info returns the build and git info in json. However, the build time and commit time are all represented in epoch timestamp.

"build": { "version": "1.1.5", "artifact": "service-artifact", "name": "Service name", "group": "some group", "time": 1594218235.671000000 }

I tried setting the following but same result.

spring.jackson.time-zone=GMT
spring.jackson.serialization.write-dates-as-timestamps=false
spring.jackson.date-format=yyyy-MM-dd

Time when converted from epoch to GMT shows correct time. We use the application to deploy to PCF and when looking from PCF AppManager, settings tab, the time incorrectly converts to Time: 01/19/70 09:59AM UTC

If the time is sent in ISO 8601 format in /info call, all seem to work. Looking for help and suggestion as to how to configure this correctly to send ISO 8601 formatted date and time from actuator /info call.

Thanks.

Upvotes: 4

Views: 1014

Answers (1)

Hakunamatata
Hakunamatata

Reputation: 1

I had a similar issue and found out that the problem was in the SwaggerConfig class. Any Configuration class which is currently implementing WebMvcConfigurer and removing the @EnableWebMvc annotation fixed the problem.

@EnableWebMvc // <--- remove
@EnableSwagger2
@Configuration
public class SwaggerConfig implements WebMvcConfigurer {
//Your configuration code block
}

Removing the above configuration fixed the epoch date format to a timestamps format i.e:

"time":1679082325.495000000    to-->    "time": "2023-04-03T16:40:22.801Z"

Hope this helps.

Upvotes: 0

Related Questions