From 2b32b904fa1c405daca2f67c77446bc679736f60 Mon Sep 17 00:00:00 2001 From: Werner Keil Date: Sat, 12 Oct 2024 22:41:00 +0200 Subject: [PATCH] Update NumberDelimiterQuantityFormat --- .../format/NumberDelimiterQuantityFormat.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/jdk17/tech/units/indriya/format/NumberDelimiterQuantityFormat.java b/src/main/jdk17/tech/units/indriya/format/NumberDelimiterQuantityFormat.java index ddd8a5ef..df6cc799 100644 --- a/src/main/jdk17/tech/units/indriya/format/NumberDelimiterQuantityFormat.java +++ b/src/main/jdk17/tech/units/indriya/format/NumberDelimiterQuantityFormat.java @@ -56,15 +56,15 @@ * @author Werner Keil * @author Thodoris Bais * - * @version 2.12, $Date: 2023-06-05 $ + * @version 2.13, $Date: 2024-10-12 $ * @since 2.0 */ @SuppressWarnings({ "rawtypes", "unchecked" }) public class NumberDelimiterQuantityFormat extends AbstractQuantityFormat { // Constants used by factory methods to specify a style of format. - private static final int DEFAULTSTYLE = 0; - private static final int COMPACTSTYLE = 1; + public static final int DEFAULTSTYLE = 0; + public static final int COMPACTSTYLE = 1; /** * Holds the default format instance (SimpleUnitFormat). @@ -209,6 +209,22 @@ public NumberDelimiterQuantityFormat build() { public static NumberDelimiterQuantityFormat getInstance(FormatBehavior behavior) { return internalGetInstance(behavior, DEFAULTSTYLE); } + + /** + * Returns an instance of {@link NumberDelimiterQuantityFormat} with a particular {@link FormatBehavior}, either locale-sensitive or locale-neutral. + * For example: NumberDelimiterQuantityFormat.getInstance(LOCALE_NEUTRAL)) returns
+ * new NumberDelimiterQuantityFormat.Builder() + .setNumberFormat(NumberFormat.getInstance(Locale.ROOT)).setUnitFormat(SimpleUnitFormat.getInstance()).build(); + * + * @param behavior + * the format behavior to apply. + * @param numberStyle + * the number format style to apply. + * @return NumberDelimiterQuantityFormat.getInstance(NumberFormat.getInstance(), UnitFormat.getInstance()) + */ + public static NumberDelimiterQuantityFormat getInstance(FormatBehavior behavior, int numberStyle) { + return internalGetInstance(behavior, numberStyle); + } /** * Returns a new instance of {@link Builder}.