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

Custom default QuantityFormat and UnitFormat #366

Open
puigru opened this issue Feb 27, 2022 · 1 comment
Open

Custom default QuantityFormat and UnitFormat #366

puigru opened this issue Feb 27, 2022 · 1 comment

Comments

@puigru
Copy link

puigru commented Feb 27, 2022

Currently, both Quantity#toString and Unit#toString default to a built-in formatter, SimpleQuantityFormat and SimpleUnitFormat.
I believe it would be useful to provide a way to set a custom formatter globally, especially for Quantity. Meaning any time a Quantity is converted to a String within the application it would use the provided formatter.

public String toString() {
return SimpleQuantityFormat.getInstance().format(this);
}

@keilw
Copy link
Member

keilw commented Jul 20, 2022

We did try this, check out the second ticket here #2, but it had so many unforseen side-effects on formatting and parsing, that we abandoned it. Feel free to fork the code and demonstrate it works, then we may revisit it, but given the built-in Date/Time library of the JDK has ultra-primitive toString() functionality in most of its core types like DateTime, LocalDateTime, etc. and Instant does exactly the same default formatting:

    public String toString() {
        return DateTimeFormatter.ISO_INSTANT.format(this);
    }

we do not feel a strong need in another value-based Java API to go beyond what the JDK felt was necessary.

@keilw keilw added the format label Jul 20, 2022
@keilw keilw added the deferred label Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants