Update LocaleUtils.java

This commit is contained in:
ShirosakiMio 2024-07-22 09:26:12 +08:00
parent daab6c5597
commit 6ecfaeef74
1 changed files with 5 additions and 1 deletions

View File

@ -85,7 +85,11 @@ public class LocaleUtils {
public static DateTimeFormatter getDateTimeFormatter(Context context) {
if (dateTimeFormatter == null) {
@SuppressLint("DiscouragedApi") int resId = context.getResources().getIdentifier("world_time", "string", context.getPackageName());
dateTimeFormatter = DateTimeFormatter.ofPattern(context.getString(resId)).withZone(ZoneId.systemDefault());
String time = "EEE, MMM d, yyyy HH:mm:ss";
if (resId != 0) {
time = context.getString(resId);
}
dateTimeFormatter = DateTimeFormatter.ofPattern(time).withZone(ZoneId.systemDefault());
}
return dateTimeFormatter;
}