www.fgks.org   »   [go: up one dir, main page]

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

Fix writing fractional seconds #49

Merged

Conversation

jpedrofigueiredo
Copy link
Contributor

What

Fractional seconds with leading zeros are parsed correctly but written back incorrectly, eg ".073" -> ".73"

This test fails in master branch:

@Test
public void testFormatWithMillisWithLeadingZero(){
    RFC3339DateFormat format = new RFC3339DateFormat();
    String formatted = format.format(new Date(1601630729073L));
    assertEquals("2020-10-02T09:25:29.073Z", formatted);
}

with

org.junit.ComparisonFailure: 
Expected :2020-10-02T09:25:29.073Z
Actual   :2020-10-02T09:25:29.73Z

Also included is a change to allow the user to choose if they always want to see 3 digits in the fractional seconds part or not, eg ".730" vs ".73", basically by not removing trailing zeros. The default is set to remove trailing zeros, thus keeping the original writing behaviour.

Joao Figueiredo added 2 commits October 2, 2020 15:53
Fractional seconds with leading zeros are parsed correctly but written
 incorrectly, eg ".066" -> ".66"

This include a change to also allow the user to choose if they always
 want to see 3 digits in the fractional part or not, eg ".730" vs ".73"
 basically removing trailing zeros
@julman99
Copy link
Owner
julman99 commented Nov 2, 2020

Nice catch! Thanks for your contribution!

@julman99 julman99 merged commit 7ad5314 into julman99:master Nov 2, 2020
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.

None yet

2 participants