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

Do not use deprecated jackson iso8601 class #2423

Conversation

SimonVerhoeven
Copy link
Contributor

The currently used Jackson ISO8601 class is deprecated

References

  • TODO

Submitter checklist

  • Recommended: Join WireMock Slack to get any help in #help-contributing or a project-specific channel like #wiremock-java
  • Recommended: If you participate in Hacktoberfest 2023, maake sure you're signed up there and in the WireMock form
  • The PR request is well described and justified, including the body and the references
  • The PR title represents the desired changelog entry
  • The repository's code style is followed (see the contributing guide)
  • Test coverage that demonstrates that the change works as expected
  • For new features, there's necessary documentation in this pull request or in a subsequent PR to wiremock.org

@SimonVerhoeven SimonVerhoeven requested a review from a team as a code owner October 7, 2023 12:39
@oleg-nenashev oleg-nenashev added the chore Maintenance label Oct 7, 2023
Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@oleg-nenashev oleg-nenashev changed the title feat: do not use deprecated jackson iso8601 class Do not use deprecated jackson iso8601 class Oct 7, 2023
@@ -30,7 +30,9 @@ public static Integer toInt(QueryParameter parameter) {

public static Date toDate(QueryParameter parameter) {
try {
return parameter.isPresent() ? new ISO8601DateFormat().parse(parameter.firstValue()) : null;
return parameter.isPresent()
? new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse(parameter.firstValue())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we changing the contract here?

I think the class we're replacing will allow milliseconds whereas it looks like this won't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah fair point, I looked upon the usages and based myself upon the usage for ParseDateHelper which does not use ms. Do you prefer a singular contract or optional ms?

@tomakehurst
Copy link
Member

How about we use java.time instead?

i.e. for formatting:

DateTimeFormatter.ISO_ZONED_DATE_TIME.format(date.toInstant().atZone(ZoneId.of('Z')));

parsing:

Date.from(ZonedDateTime.parse(isoDateTimeString).toInstant())

@oleg-nenashev oleg-nenashev merged commit bbef0c2 into wiremock:master Oct 17, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants