Skip to content

Fix writing fractional seconds#49

Merged
julman99 merged 2 commits into
julman99:masterfrom
jpedrofigueiredo-graveyard:rfc3339-millis-with-leading-zeros
Nov 2, 2020
Merged

Fix writing fractional seconds#49
julman99 merged 2 commits into
julman99:masterfrom
jpedrofigueiredo-graveyard:rfc3339-millis-with-leading-zeros

Conversation

@jpedrofigueiredo

@jpedrofigueiredo jpedrofigueiredo commented Oct 2, 2020

Copy link
Copy Markdown
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.


Open with Devin

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

julman99 commented Nov 2, 2020

Copy link
Copy Markdown
Owner

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.

2 participants