Skip to content

Use RFC 822 format for marshalling date shapes #3452

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

Merged
merged 2 commits into from
Oct 4, 2022

Conversation

dave-fn
Copy link
Contributor

@dave-fn dave-fn commented Sep 30, 2022

Add utility method so that dates are marshalled using RFC 822 format.

Motivation and Context

The formatted representation of dates with single-digit day of month also includes a single-digit. This code fix will change the representation to two-digit day of month.

Current:

Expires: Fri, 1 Sep 2023 01:01:01 GMT.

Expected:

Expires: Fri, 01 Sep 2023 01:01:01 GMT

Modifications

Modified DateUtils.java to add parse and format methods specific to RFC 822. Cascaded these changes to other modules.

Testing

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@dave-fn dave-fn requested a review from a team as a code owner September 30, 2022 18:21
@dave-fn dave-fn requested a review from joviegas October 3, 2022 13:44
.appendLiteral(' ')
.appendOffset("+HHMM", "GMT")
.toFormatter()
.withLocale(Locale.US);
Copy link
Contributor

@joviegas joviegas Oct 3, 2022

Choose a reason for hiding this comment

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

  • I guess the reason for Locale.US is V1-refernce, correct me if I am wrong.
  • Why are we not doing
toFormatter(ResolverStyle.SMART, IsoChronology.INSTANCE)

same as done in RFC_1123_DATE_TIME ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Right, Locale.US was chosen to match V1.
  • Unfortunately, that access modifier on that method is package access. The two (1, 2) public toFormatter methods do default to ResolverStyle.SMART as of Java 8, though.

Copy link
Contributor Author

@dave-fn dave-fn Oct 3, 2022

Choose a reason for hiding this comment

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

I guess an alternative would be to set the ResolverStye.SMART and IsoChonology.INSTANCE values on the DateTimeFormatter object after it's been built. Let me know if you'd prefer me to make that change.

Copy link
Contributor

@joviegas joviegas Oct 3, 2022

Choose a reason for hiding this comment

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

Yeap , we can set it after its been built.
Can we add some test cases where we can test this too (ResolverStye and IsoChonology)?
We can compare the same with RFC_1123_DATE_TIME

@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 4, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

85.0% 85.0% Coverage
0.0% 0.0% Duplication

@dave-fn dave-fn merged commit 377f2a2 into aws:master Oct 4, 2022
@dave-fn dave-fn deleted the davidfn/rfc-822-marshalled-date-shapes branch October 4, 2022 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants