You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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.
indriya/src/main/java/tech/units/indriya/AbstractQuantity.java
Lines 295 to 297 in cb717f7
The text was updated successfully, but these errors were encountered: