MeasureFormat Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
MeasureFormat(IntPtr, JniHandleOwnership) |
Properties
Class |
Returns the runtime class of this |
CurrencyFormat |
Return a formatter for CurrencyAmount objects in the default |
Handle |
The handle to the underlying Android instance. (Inherited from Object) |
JniIdentityHashCode | (Inherited from Object) |
JniPeerMembers | |
Locale |
Get the locale of this instance. |
NumberFormat |
Get a copy of the number format. |
PeerReference | (Inherited from Object) |
ThresholdClass | |
ThresholdType | |
Width |
Methods
Clone() |
Creates and returns a copy of this object. (Inherited from _Format) |
Dispose() | (Inherited from Object) |
Dispose(Boolean) | (Inherited from Object) |
Equals(Object) |
Two MeasureFormats, a and b, are equal if and only if they have the same formatWidth, locale, and equal number formats. |
Format(Object, StringBuffer, FieldPosition) |
Able to format Collection<? extends Measure>, 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[]) | |
FormatMeasures(StringBuilder, FieldPosition, Measure[]) | |
FormatToCharacterIterator(Object) |
Formats an Object producing an |
GetCurrencyFormat(Locale) |
Return a formatter for CurrencyAmount objects in the given |
GetCurrencyFormat(ULocale) |
Return a formatter for CurrencyAmount objects in the given locale. |
GetHashCode() |
To be added |
GetInstance(Locale, MeasureFormat+FormatWidth, NumberFormat) | |
GetInstance(Locale, MeasureFormat+FormatWidth) | |
GetInstance(ULocale, MeasureFormat+FormatWidth, NumberFormat) | |
GetInstance(ULocale, MeasureFormat+FormatWidth) | |
GetUnitDisplayName(MeasureUnit) |
Gets the display name of the specified |
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 |
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) |
ToArray<T>() | (Inherited from Object) |
ToString() |
Returns a string representation of the object. (Inherited from Object) |
UnregisterFromRuntime() | (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
IJavaPeerable.Disposed() | (Inherited from Object) |
IJavaPeerable.DisposeUnlessReferenced() | (Inherited from Object) |
IJavaPeerable.Finalized() | (Inherited from Object) |
IJavaPeerable.JniManagedPeerState | (Inherited from Object) |
IJavaPeerable.SetJniIdentityHashCode(Int32) | (Inherited from Object) |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) | (Inherited from Object) |
IJavaPeerable.SetPeerReference(JniObjectReference) | (Inherited from Object) |
Extension Methods
JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
JavaCast<TResult>(IJavaObject) | |
GetJniTypeName(IJavaPeerable) |
Gets the JNI name of the type of the instance |
JavaAs<TResult>(IJavaPeerable) |
Try to coerce |
TryJavaCast<TResult>(IJavaPeerable, TResult) |
Try to coerce |