diff --git a/src/main/java/tech/units/indriya/format/NumberDelimiterQuantityFormat.java b/src/main/java/tech/units/indriya/format/NumberDelimiterQuantityFormat.java index 2a65a254..7ce339cc 100644 --- a/src/main/java/tech/units/indriya/format/NumberDelimiterQuantityFormat.java +++ b/src/main/java/tech/units/indriya/format/NumberDelimiterQuantityFormat.java @@ -56,7 +56,7 @@ * @author Werner Keil * @author Thodoris Bais * - * @version 2.5, $Date: 2021-05-09 $ + * @version 2.6, $Date: 2021-05-10 $ * @since 2.0 */ @SuppressWarnings({ "rawtypes", "unchecked" }) @@ -238,15 +238,17 @@ public static NumberDelimiterQuantityFormat getInstance(NumberFormat numberForma } /** - * Returns an instance of {@link NumberDelimiterQuantityFormat} with a particular {@link FormatBehavior}, either locale-sensitive or locale-neutral. + * Returns a compact 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(); * + * @implNote This is a stub that won't work prior to Java 12 because the CompactNumberFormat used by it does not exist before Java 12. * @param behavior * the format behavior to apply. * @return NumberDelimiterQuantityFormat.getInstance(NumberFormat.getInstance(), UnitFormat.getInstance()) * @since 2.5 + * @throws UnsupportedOperationException prior to Java 12 */ public static NumberDelimiterQuantityFormat getCompactInstance(FormatBehavior behavior) { throw new UnsupportedOperationException("This method requires Java 12."); diff --git a/src/main/jdk12/tech/units/indriya/format/NumberDelimiterQuantityFormat.java b/src/main/jdk12/tech/units/indriya/format/NumberDelimiterQuantityFormat.java index 7904f439..56edc61b 100644 --- a/src/main/jdk12/tech/units/indriya/format/NumberDelimiterQuantityFormat.java +++ b/src/main/jdk12/tech/units/indriya/format/NumberDelimiterQuantityFormat.java @@ -214,8 +214,7 @@ public static NumberDelimiterQuantityFormat getInstance(FormatBehavior behavior) /** * 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(); + * new NumberDelimiterQuantityFormat.Builder().setNumberFormat(NumberFormat.getCompactNumberInstance(Locale.ROOT, NumberFormat.Style.SHORT)).setUnitFormat(SimpleUnitFormat.getInstance()).build(); * * @param behavior * the format behavior to apply.