Skip to content

Commit

Permalink
ICU-23032 Update MeasureUnit documentation for forIdentifier method
Browse files Browse the repository at this point in the history
  • Loading branch information
younies authored and Squash Bot committed Jan 31, 2025
1 parent cb43440 commit c86558d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
15 changes: 9 additions & 6 deletions icu4c/source/i18n/unicode/measunit.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,16 +430,19 @@ class U_I18N_API MeasureUnit: public UObject {
MeasureUnit(MeasureUnit &&other) noexcept;

/**
* Construct a MeasureUnit from a CLDR Core Unit Identifier, defined in UTS
* 35. (Core unit identifiers and mixed unit identifiers are supported, long
* unit identifiers are not.) Validates and canonicalizes the identifier.
* Constructs a MeasureUnit from a CLDR Core Unit Identifier, as defined in UTS 35.
* This method supports core unit identifiers and mixed unit identifiers.
* It validates and canonicalizes the given identifier.
*
*
* Example usage:
* <pre>
* MeasureUnit example = MeasureUnit::forIdentifier("furlong-per-nanosecond")
* MeasureUnit example = MeasureUnit.forIdentifier("meter-per-second");
* </pre>
*
* @param identifier The CLDR Unit Identifier.
* @param status Set if the identifier is invalid.
* @param identifier the CLDR Unit Identifier
* @param status Set error if the identifier is invalid.
* @return the corresponding MeasureUnit
* @stable ICU 67
*/
static MeasureUnit forIdentifier(StringPiece identifier, UErrorCode& status);
Expand Down
21 changes: 13 additions & 8 deletions icu4j/main/core/src/main/java/com/ibm/icu/util/MeasureUnit.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,19 +411,24 @@ protected MeasureUnit(String type, String subType) {
}

/**
* Construct a MeasureUnit from a CLDR Core Unit Identifier, defined in UTS
* 35. (Core unit identifiers and mixed unit identifiers are supported, long
* unit identifiers are not.) Validates and canonicalizes the identifier.
* Constructs a MeasureUnit from a CLDR Core Unit Identifier, as defined in UTS
* 35.
* This method supports core unit identifiers and mixed unit identifiers.
* It validates and canonicalizes the given identifier.
*
* Note: dimensionless <code>MeasureUnit</code> is <code>null</code>
* Note: A dimensionless <code>MeasureUnit</code> is represented as
* <code>null</code>.
*
* Example usage:
*
* <pre>
* MeasureUnit example = MeasureUnit::forIdentifier("furlong-per-nanosecond")
* MeasureUnit example = MeasureUnit::forIdentifier("meter-per-second, status);
* </pre>
*
* @param identifier CLDR Unit Identifier
* @throws IllegalArgumentException if the identifier is invalid.
* @stable ICU 68
* @param identifier the CLDR Unit Identifier
* @return the corresponding MeasureUnit
* @throws IllegalArgumentException if the identifier is invalid
* @stable ICU 67
*/
public static MeasureUnit forIdentifier(String identifier) {
if (identifier == null || identifier.isEmpty()) {
Expand Down

0 comments on commit c86558d

Please sign in to comment.