Fix the date format alignment problem

- The date format is different between "Android security update"
  and "Google Play system update" for locale TH.
- Use the same getBestDateTimePattern API to align the format.

Fixes: 331897617
Test: atest MainlineModuleVersionPreferenceControllerTest
Change-Id: I346749594b05703b601d0d84fd7659fd3c2fa85a
This commit is contained in:
Sunny Shao
2024-04-12 08:21:03 +08:00
parent 00edf33615
commit b839b6f81a

View File

@@ -80,7 +80,6 @@ public class MainlineModuleVersionPreferenceController extends BasePreferenceCon
try {
mModuleVersion =
mPackageManager.getPackageInfo(moduleProvider, 0 /* flags */).versionName;
return;
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Failed to get mainline version.", e);
mModuleVersion = null;
@@ -124,7 +123,8 @@ public class MainlineModuleVersionPreferenceController extends BasePreferenceCon
return mModuleVersion;
}
return DateFormat.getLongDateFormat(mContext).format(parsedDate.get());
String format = DateFormat.getBestDateTimePattern(Locale.getDefault(), "dMMMMyyyy");
return DateFormat.format(format, parsedDate.get());
}
private Optional<Date> parseDateFromVersionName(String text) {