Skip to content

Flight SQL JDBC interval strings use the default locale for digits #1311

Description

@Arawoof06

IntervalStringUtils.formatIntervalYear and formatIntervalDay build the Oracle-style INTERVAL YEAR TO MONTH / INTERVAL DAY TO SECOND strings that the JDBC interval accessor returns from getString()/getObject() with String.format("...%d...", ...) and no explicit Locale. java.util.Formatter localises %d digits with the JVM default locale, so on a JVM whose default locale uses non-ASCII digits (e.g. ar-EG, bn-BD, mr-IN) an interval renders as +٠٢١-٠٢ instead of +021-02. The value handed back to JDBC clients is then non-ASCII and any downstream code that parses it as [+-]YYY-MM / [+-]DDD HH:MM:SS.mmm breaks.

This is the same root cause as GH-1300 (C Data Interface format strings), just in the JDBC layer. Fix is to pass Locale.ROOT to the two String.format calls.

Reproduction

Locale.setDefault(Locale.forLanguageTag("ar-EG"));
IntervalStringUtils.formatIntervalYear(Period.of(21, 2, 0)); // returns "+٠٢١-٠٢", expected "+021-02"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions