Skip to content

Use ISO standard for week of week based year #42588

@pgomulka

Description

@pgomulka

In java.time week of weekbased year is depending on Locale. The locale we use is ROOT, and it does not define the start of the week.
Therefore start of the week can be either Sunday or Monday.
ISO 8601 defines start of the week as Monday, and that standard was used in Joda for week of week based year.
This would fail because of that change.
2019-21 (ok joda) vs 2019-22 (java)

 ZonedDateTime now = LocalDateTime.of(2019,5,26,1,32,8,328402)
                                         .atZone(ZoneOffset.UTC);
        DateFormatter jodaFormatter = Joda.forPattern("xxxx-ww").withLocale(Locale.ROOT).withZone(ZoneOffset.UTC);
        DateFormatter javaFormatter = DateFormatter.forPattern("8YYYY-ww").withLocale(Locale.ROOT).withZone(ZoneOffset.UTC);
        assertThat(jodaFormatter.format(now), equalTo(javaFormatter.format(now)));

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions