Incorrect localization of dark theme custom time

Fixes: 154361883
Test: manually select dark theme custom time and make sure it matches
locale

Change-Id: I2a918b4b2f5aad6b04d3b0318bbca25e82dfae78
This commit is contained in:
Jay Aliomer
2020-05-27 22:21:32 -04:00
parent 69d210c7df
commit 57cc7d01ae
2 changed files with 8 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ import android.content.Context;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
/**
* Formats LocalTime to the locale time string format
@@ -28,11 +29,15 @@ public class TimeFormatter {
private final DateTimeFormatter mFormatter;
public TimeFormatter(Context context) {
mContext = context;
mFormatter = DateTimeFormatter.ofPattern("hh:mm a");
Locale locale = mContext.getResources().getConfiguration().locale;
if (locale == null) {
locale = Locale.getDefault();
}
mFormatter = DateTimeFormatter.ofPattern("hh:mm a", locale);
}
public String of(LocalTime time) {
return is24HourFormat() ? time.toString() : mFormatter.format(time);
return mFormatter.format(time);
}
public boolean is24HourFormat() {