Skip to content

Detection of DurationStyle.ISO8601 does not support lower-case input #32218

@valentine-dev

Description

@valentine-dev

Bug Report

Environment

Version of Spring Boot

2.7.3

Version of Java

11

Expected (what is in the Reference Documentation)

The standard ISO-8601 format used by java.time.Duration

from https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.external-config.typesafe-configuration-properties.conversion.durations

Actual Behavior

Some format used by java.time.Duration is not working in Spring Boot app, like "pt25.234s" demonstrated in the example application at https://github.com/valentine-dev/spring-boot-duration-style-iso8601

Suggestion Solution

  1. Add Pattern.CASE_INSENSITIVE as the second argument to the Pattern.compile method at Line 87 of DurationStyle.java
  2. Use the following pattern string in java.time.Duration source code (Line 151 ~ 152 in the file from JDK 11) at Line 65 of DurationStyle.java:

"([-+]?)P(?:([-+]?[0-9]+)D)?" +
"(T(?:([-+]?[0-9]+)H)?(?:([-+]?[0-9]+)M)?(?:([-+]?[0-9]+)(?:[.,]([0-9]{0,9}))?S)?)?"

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by another

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions