由于静态 ThreadLocal 缓存,在系统语言更改时,NumberUtils 格式化无法更新

作者: QiuYucheng2003创建于 2026年2月11日更新于 2026年2月11日
标签bug

Description of the bug NumberUtils class uses a static ThreadLocal (DF_THREAD_LOCAL) cache to store the formatting object. The initialValue() method is only executed when the thread is first called, and captures the current Locale.getDefault(). If the user switches the system language (for example, from English to German) during the App's execution, the DecimalFormat in the ThreadLocal will not be rebuilt, and will still hold the old Locale configuration. This will result in inconsistent number formatting (such as the decimal point symbol . vs ,) and some interfaces will display the old language format, while others will display the new language format. - Version of AndroidUtilCode: 1.29.0 - Device model on which the bug occurs: All (general logic problem) - Android version of the device: All

内容来源: Blankj/AndroidUtilCode