Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimeUtils切换语言时会有bug #1786

Open
keyingming opened this issue Aug 17, 2023 · 0 comments
Open

TimeUtils切换语言时会有bug #1786

keyingming opened this issue Aug 17, 2023 · 0 comments
Assignees
Labels

Comments

@keyingming
Copy link

描述 Bug

1.在中文环境下,使用TimeUtils.millis2String(long millis, @nonnull final String pattern)方法,pattern传入:h:mm a,获取到的时间能正常显示,如:8:00上午
2.切换系统语言为其他语言,此时重复上面的步骤,获取到的时间显示不对,在其他语言环境下,仍显示:8:00上午,显示错误

  • AndroidUtilCode 的版本:utilscodex:1.31.1
  • 出现 Bug 的设备型号:华为畅享50
  • 设备的 Android 版本:Android 10

查看源码,TimeUtils类里的SDF_THREAD_LOCAL里面已经缓存了SimpleDateFormat,切换语言时,因为h:mm a使用过,缓存在SDF_THREAD_LOCAL,不会重新添加,但此时的simpleDateFormat是在中文环境创建的,导致出来的时间一直是中文,切换了语言也不会变……

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants