Skip to content

Commit

Permalink
413: Parsing of 1/mile is not possible
Browse files Browse the repository at this point in the history
Task-Url: #413
  • Loading branch information
keilw committed Oct 12, 2024
1 parent 2b32b90 commit a598ac6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
* @author <a href="mailto:[email protected]">Werner Keil</a>
* @author <a href="mailto:[email protected]">Thodoris Bais</a>
*
* @version 2.8, $Date: 2023-06-05 $
* @version 2.9, $Date: 2024-10-12 $
* @since 2.0
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
Expand Down Expand Up @@ -206,6 +206,25 @@ public static NumberDelimiterQuantityFormat getInstance(final FormatBehavior beh
}
}

/**
* Returns an instance of {@link NumberDelimiterQuantityFormat} with a particular {@link FormatBehavior}, either locale-sensitive or locale-neutral,
* and a desired number style.<br>
* For example: <code>NumberDelimiterQuantityFormat.getInstance(LOCALE_NEUTRAL))</code> returns<br>
* <code>new NumberDelimiterQuantityFormat.Builder().setNumberFormat(NumberFormat.getInstance(Locale.ROOT)).setUnitFormat(SimpleUnitFormat.getInstance()).build();</code>
* @implNote
* Note: <code>numberStyle</code> will be ignored before Java 17. Although the <code>COMPACT</code> {@linkplain NumberFormat} is already available from Java 12, Indriya supports major LTS versions like 8, 11 or 17.
*
* @param behavior
* the format behavior to apply.
* @param numberStyle
* the number format style to apply.
* @return <code>NumberDelimiterQuantityFormat.getInstance(NumberFormat.getInstance(), UnitFormat.getInstance())</code>
* @since 2.9
*/
public static NumberDelimiterQuantityFormat getInstance(final FormatBehavior behavior, int numberStyle) {
return getInstance(behavior);
}

/**
* Returns a new instance of {@link Builder}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,19 @@ public static NumberDelimiterQuantityFormat getInstance(FormatBehavior behavior)
}

/**
* Returns an instance of {@link NumberDelimiterQuantityFormat} with a particular {@link FormatBehavior}, either locale-sensitive or locale-neutral.
* Returns an instance of {@link NumberDelimiterQuantityFormat} with a particular {@link FormatBehavior}, either locale-sensitive or locale-neutral,
* and a desired number style.<br>
* For example: <code>NumberDelimiterQuantityFormat.getInstance(LOCALE_NEUTRAL))</code> returns<br>
* <code>new NumberDelimiterQuantityFormat.Builder()
.setNumberFormat(NumberFormat.getInstance(Locale.ROOT)).setUnitFormat(SimpleUnitFormat.getInstance()).build();</code>
*
* <code>new NumberDelimiterQuantityFormat.Builder().setNumberFormat(NumberFormat.getInstance(Locale.ROOT)).setUnitFormat(SimpleUnitFormat.getInstance()).build();</code>
* @implNote
* Note: <code>numberStyle</code> will be ignored before Java 17. Although the <code>COMPACT</code> {@linkplain NumberFormat} is already available from Java 12, Indriya supports major LTS versions like 8, 11 or 17.
*
* @param behavior
* the format behavior to apply.
* @param numberStyle
* the number format style to apply.
* @return <code>NumberDelimiterQuantityFormat.getInstance(NumberFormat.getInstance(), UnitFormat.getInstance())</code>
* @since 2.13
*/
public static NumberDelimiterQuantityFormat getInstance(FormatBehavior behavior, int numberStyle) {
return internalGetInstance(behavior, numberStyle);
Expand Down Expand Up @@ -413,7 +416,7 @@ public MixedQuantity<?> parseMixed(CharSequence csq) throws IllegalArgumentExcep
* @return <code>NumberDelimiterQuantityFormat.getInstance(NumberFormat.getInstance(), UnitFormat.getInstance())</code>
* @since 2.5
*/
private static NumberDelimiterQuantityFormat internalGetInstance(FormatBehavior behavior, int numberStyle) {
private static NumberDelimiterQuantityFormat internalGetInstance(final FormatBehavior behavior, int numberStyle) {
switch (behavior) {
case LOCALE_SENSITIVE:
return LOCAL_INSTANCE;
Expand Down

0 comments on commit a598ac6

Please sign in to comment.