Language

MeasureFormat Class

Definition

A formatter for Measure objects.

[Android.Runtime.Register("android/icu/text/MeasureFormat", ApiSince=24, DoNotGenerateAcw=true)]
public class MeasureFormat : Android.Icu.Text.UFormat
[<Android.Runtime.Register("android/icu/text/MeasureFormat", ApiSince=24, DoNotGenerateAcw=true)>]
type MeasureFormat = class
    inherit UFormat
Inheritance
Attributes

Remarks

A formatter for Measure objects.

<strong>IMPORTANT:</strong> New users are strongly encouraged to see if NumberFormatter fits their use case. Although not deprecated, this class, MeasureFormat, is provided for backwards compatibility only, and has much more limited capabilities. <hr>

To format a Measure object, first create a formatter object using a MeasureFormat factory method. Then use that object's format or formatMeasures methods.

Here is sample code:

MeasureFormat fmtFr = MeasureFormat.getInstance(ULocale.FRENCH, FormatWidth.SHORT);
            Measure measure = new Measure(23, MeasureUnit.CELSIUS);

            // Output: 23 °C
            System.out.println(fmtFr.format(measure));

            Measure measureF = new Measure(70, MeasureUnit.FAHRENHEIT);

            // Output: 70 °F
            System.out.println(fmtFr.format(measureF));

            MeasureFormat fmtFrFull = MeasureFormat.getInstance(ULocale.FRENCH, FormatWidth.WIDE);
            // Output: 70 pieds et 5,3 pouces
            System.out.println(fmtFrFull.formatMeasures(new Measure(70, MeasureUnit.FOOT),
                    new Measure(5.3, MeasureUnit.INCH)));

            // Output: 1 pied et 1 pouce
            System.out.println(
                    fmtFrFull.formatMeasures(new Measure(1, MeasureUnit.FOOT), new Measure(1, MeasureUnit.INCH)));

            MeasureFormat fmtFrNarrow = MeasureFormat.getInstance(ULocale.FRENCH, FormatWidth.NARROW);
            // Output: 1′ 1″
            System.out.println(fmtFrNarrow.formatMeasures(new Measure(1, MeasureUnit.FOOT),
                    new Measure(1, MeasureUnit.INCH)));

            MeasureFormat fmtEn = MeasureFormat.getInstance(ULocale.ENGLISH, FormatWidth.WIDE);

            // Output: 1 inch, 2 feet
            fmtEn.formatMeasures(new Measure(1, MeasureUnit.INCH), new Measure(2, MeasureUnit.FOOT));

This class does not do conversions from one unit to another. It simply formats whatever units it is given

This class is immutable and thread-safe so long as its deprecated subclass, TimeUnitFormat, is never used. TimeUnitFormat is not thread-safe, and is mutable. Although this class has existing subclasses, this class does not support new sub-classes.

Java documentation for android.icu.text.MeasureFormat.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Name Description
MeasureFormat(IntPtr, JniHandleOwnership)

Properties

Name Description
Class

Returns the runtime class of this Object.

(Inherited from Object)
CurrencyFormat

Return a formatter for CurrencyAmount objects in the default FORMAT locale.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode

Gets the identity hash code assigned to this Java peer by the interop runtime.

(Inherited from Object)
JniManagedPeerState (Inherited from JavaObject)
JniPeerMembers
Locale

Get the locale of this instance.

NumberFormat

Get a copy of the number format.

PeerReference

Gets the JNI object reference for this Java peer.

(Inherited from Object)
ThresholdClass
ThresholdType
Width

Get the format width this instance is using.

Methods

Name Description
Clone()

Creates and returns a copy of this object.

(Inherited from _Format)
Construct(JniObjectReference, JniObjectReferenceOptions) (Inherited from JavaObject)
Dispose()

Releases the resources held by this Java peer.

(Inherited from Object)
Dispose(Boolean)

Releases the resources held by this Java peer.

(Inherited from Object)
DisposeUnlessReferenced() (Inherited from JavaObject)
Equals(Object)

Two MeasureFormats, a and b, are equal if and only if they have the same formatWidth, locale, and equal number formats.

Equals(Object) (Inherited from JavaObject)
Format(Object, StringBuffer, FieldPosition)

Able to format Collection&lt;? extends Measure&gt;, Measure[], and Measure by delegating to formatMeasures.

Format(Object)

Formats an object to produce a string.

(Inherited from _Format)
FormatMeasurePerUnit(Measure, MeasureUnit, StringBuilder, FieldPosition)

Formats a single measure per unit.

FormatMeasures(Measure[])

Format a sequence of measures.

FormatMeasures(StringBuilder, FieldPosition, Measure[])

Formats a sequence of measures.

FormatToCharacterIterator(Object)

Formats an Object producing an AttributedCharacterIterator.

(Inherited from _Format)
GetCurrencyFormat(Locale)

Return a formatter for CurrencyAmount objects in the given java.util.Locale.

GetCurrencyFormat(ULocale)

Return a formatter for CurrencyAmount objects in the given locale.

GetHashCode()

Returns a hash code value for the object.

GetInstance(Locale, MeasureFormat+FormatWidth, NumberFormat)

Create a format from the Locale, formatWidth, and format.

GetInstance(Locale, MeasureFormat+FormatWidth)

Create a format from the Locale and formatWidth.

GetInstance(ULocale, MeasureFormat+FormatWidth, NumberFormat)

Create a format from the locale, formatWidth, and format.

GetInstance(ULocale, MeasureFormat+FormatWidth)

Create a format from the locale, formatWidth, and format.

GetUnitDisplayName(MeasureUnit)

Gets the display name of the specified MeasureUnit corresponding to the current locale and format width.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
ParseObject(String, ParsePosition)

Parses text from a string to produce a Measure.

ParseObject(String)

Parses text from the beginning of the given string to produce an object.

(Inherited from _Format)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetPeerReference(JniObjectReference, JniObjectReferenceOptions) (Inherited from JavaObject)
ToArray<T>()

Creates a managed array from this Java array wrapper.

(Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime()

Unregisters this Java peer from the interop runtime.

(Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

Name Description
IJavaPeerable.Disposed() (Inherited from JavaObject)
IJavaPeerable.Finalized() (Inherited from JavaObject)
IJavaPeerable.JniObjectReferenceControlBlock (Inherited from JavaObject)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from JavaObject)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from JavaObject)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from JavaObject)
IJavaPeerable.UnregisterFromRuntime() (Inherited from _Format)

Extension Methods

Name Description
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to