DecimalFormat.DecimalPatternMatchRequired 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定解析時是否檢查小數點。
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
屬性值
true 如果小數點檢查已啟用;否則, false。
- 屬性
備註
財產取得者文件:
回傳解析時是否啟用小數點檢查。
Java 文件 android.icu.text.DecimalFormat.isDecimalPatternMatchRequired()。
屬性設定文件:
[icu]解析: 啟用對被解析字串的小數點檢查。 此檢查預設為停用,可選擇寬鬆模式或嚴格模式使用。
在 Android 7.0 到 8.1 上,檢查結果並不總是符合這個模式。 例如,使用美國十進位符號時,它可以接受「1.5」代表模式「0」,或拒絕「0.1」代表模式「0.0」。
在 Android 17 及以後版本中,NaN 和 Infinity 不受此檢查限制。
在 Android 9 及以後版本中,若要 要求 小數點,請將此方法與包含小數點的模式或搭配 #setDecimalSeparatorAlwaysShown呼叫。
// Require a decimal point in the string being parsed:
df.applyPattern("#.");
df.setDecimalPatternMatchRequired(true);
// Alternatively:
df.setDecimalSeparatorAlwaysShown(true);
df.setDecimalPatternMatchRequired(true);
在 Android 9 及以後版本中,若要 禁止 小數點,請將此方法與不含小數點的模式結合使用。 或者,也可以在 #setParseIntegerOnly 小數點停止解析,而不必依賴模式字串的內容。
// Forbid a decimal point in the string being parsed:
df.applyPattern("#");
df.setDecimalPatternMatchRequired(true);
Java 文件 android.icu.text.DecimalFormat.setDecimalPatternMatchRequired(boolean)。
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。