Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document expected format for commit.time and build.time in git.properties #10392

Closed
allnightlong opened this issue Sep 23, 2017 · 3 comments
Closed
Labels
type: documentation A documentation update
Milestone

Comments

@allnightlong
Copy link

For this specific date format GitProperties converting it back to timestamp, so it's not possible to format my git commit date with this template.

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 23, 2017
@wilkinsona
Copy link
Member

wilkinsona commented Sep 23, 2017

Sorry, I don't understand the problem that you're trying to report.

The time is deliberately converted to epoch time so that it's in a consistent format. This time is then exposed as a Date. Typically, this Date will be serialised to JSON by Jackson when looking at Actuator's info endpoint. The formatting can then be controlled by Jackson's configuration (serialisation of dates as timestamps, date format, etc).

Can you please describe your problem in more detail? A detailed description of the behaviour that you are seeing and the behaviour that you expect to see would be useful. A failing test case would be even better.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Sep 23, 2017
@allnightlong
Copy link
Author

Sure, I can describe the case.
I'm using 'com.gorylenko.gradle-git-properties' gradle plugin (https://github.com/n0mer/gradle-git-properties) to add git.properties to my jar.
This plugin provides 2 params: 'dateFormat' and 'dateFormatTimeZone' (names are self-explanatory)

So if I provide any correct dateFormat to my gradle.properties file, I'm basically getting what I'm expecting. For example, for dateFormat = "yyyy-MM-dd'T'HH:mmZ", I've got such json from my /info endpoint:
2017-09-23_22-27-20
Hence, there is no seconds in this date format.

But for one specific dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ", spring-boot formats my time to currentTimeMillis:
2017-09-23_22-30-05
First of all, this is counter-intuitive (honestly, I've spend quite some time to get to the very reason of that). I would ignore this date format, but, apparently, it's ISO 8601 format, which is kinda useful for my purposes.

If it is difficult to change this behavior to more predictable due to compatibility issues, may be it is possible to provide 2 fields in resulting json: 1st is changed and 2nd - unchanged?

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Sep 23, 2017
@wilkinsona
Copy link
Member

wilkinsona commented Sep 25, 2017

Thanks, I think I understand what's happening now.

Boot's GitProperties expects the commit time to be formatted with yyyy-MM-dd'T'HH:mm:ssZ. When it is, that value is coerced into a long (epoch time) and then exposed as a Date. This is what's happening in your second example. Jackson has formatted the Date as a timestamp (presumably because that's what you've configured it to do).

When the commit time doesn't match the expected format it's left as-is and as a String. With management.info.git.mode=full enabled it's then exposed as a String in that format and won't be affected by Jackson's date formatting configuration as Jackson has no way of knowing that it's a date.

When you use yyyy-MM-dd'T'HH:mm:ssZ as the format for the time in git.properties, Boot is currently working as designed and you need to configure Jackson to serialise the Date into your desired format. This is the recommended approach as it means that commit time will be formatted the same as any other Date that your application serialises to JSON.

Given that both the Maven and Gradle plugins for generating git.properties allow the date format for the commit time to be configured, we should document the expected format for the commit time in git.properties so that users can configure it as required.

@wilkinsona wilkinsona added priority: normal type: documentation A documentation update and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Sep 25, 2017
@wilkinsona wilkinsona added this to the 1.5.8 milestone Sep 25, 2017
@wilkinsona wilkinsona changed the title It is not possible to format git commit date with "yyyy-MM-dd'T'HH:mm:ssZ" template Document expected format for commit.time and build.time in git.properties Sep 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

3 participants