Language

DecimalFormat.DecimalPatternMatchRequired Property

Definition

Gets or sets whether to check the decimal point when parsing.

public virtual bool DecimalPatternMatchRequired { [Android.Runtime.Register("isDecimalPatternMatchRequired", "()Z", "GetIsDecimalPatternMatchRequiredHandler", ApiSince=24)] get; [Android.Runtime.Register("setDecimalPatternMatchRequired", "(Z)V", "GetSetDecimalPatternMatchRequired_ZHandler", ApiSince=24)] set; }
[<get: Android.Runtime.Register("isDecimalPatternMatchRequired", "()Z", "GetIsDecimalPatternMatchRequiredHandler", ApiSince=24)>]
[<set: Android.Runtime.Register("setDecimalPatternMatchRequired", "(Z)V", "GetSetDecimalPatternMatchRequired_ZHandler", ApiSince=24)>]
member this.DecimalPatternMatchRequired : bool with get, set

Property Value

true if the decimal-point check is enabled; otherwise, false.

Attributes

Remarks

Property getter documentation:

Returns whether the decimal-point check is enabled when parsing.

Java documentation for android.icu.text.DecimalFormat.isDecimalPatternMatchRequired().

Property setter documentation:

[icu] Parsing: Enables a decimal-point check for the string being parsed. The check is disabled by default and can be used in either lenient mode or strict mode.

On Android 7.0 through 8.1, the check does not always match the pattern. For example, with U.S. decimal symbols, it can accept "1.5" for pattern "0" or reject "0.1" for pattern "0.0".

On Android 17 and later, NaN and infinity are not subject to this check.

On Android 9 and later, to require a decimal point, call this method in combination with either a pattern containing a decimal point or with #setDecimalSeparatorAlwaysShown.

// Require a decimal point in the string being parsed:
            df.applyPattern("#.");
            df.setDecimalPatternMatchRequired(true);

            // Alternatively:
            df.setDecimalSeparatorAlwaysShown(true);
            df.setDecimalPatternMatchRequired(true);

On Android 9 and later, to forbid a decimal point, call this method in combination with a pattern containing no decimal point. Alternatively, use #setParseIntegerOnly to stop parsing at the decimal point without depending on the contents of the pattern string.

// Forbid a decimal point in the string being parsed:
            df.applyPattern("#");
            df.setDecimalPatternMatchRequired(true);

Java documentation for android.icu.text.DecimalFormat.setDecimalPatternMatchRequired(boolean).

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.

Applies to