From b2ea588b5479c7e1aa0b40932c9734f5389258db Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Tue, 2 Jan 2024 19:21:07 +0100 Subject: Use localized date format (#6843) --- .../ui/statistics/subscriptions/PlaybackStatisticsListAdapter.java | 4 +++- .../ui/statistics/subscriptions/StatisticsFilterDialog.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'ui/statistics') diff --git a/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/subscriptions/PlaybackStatisticsListAdapter.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/subscriptions/PlaybackStatisticsListAdapter.java index 3936118ca..9b1f234c8 100644 --- a/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/subscriptions/PlaybackStatisticsListAdapter.java +++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/subscriptions/PlaybackStatisticsListAdapter.java @@ -1,5 +1,6 @@ package de.danoeh.antennapod.ui.statistics.subscriptions; +import android.text.format.DateFormat; import androidx.fragment.app.Fragment; import de.danoeh.antennapod.core.storage.StatisticsItem; import de.danoeh.antennapod.core.util.Converter; @@ -39,7 +40,8 @@ public class PlaybackStatisticsListAdapter extends StatisticsListAdapter { if (includeMarkedAsPlayed) { return context.getString(R.string.statistics_counting_total); } - SimpleDateFormat dateFormat = new SimpleDateFormat("MMM yyyy", Locale.getDefault()); + String skeleton = DateFormat.getBestDateTimePattern(Locale.getDefault(), "MMM yyyy"); + SimpleDateFormat dateFormat = new SimpleDateFormat(skeleton, Locale.getDefault()); String dateFrom = dateFormat.format(new Date(timeFilterFrom)); // FilterTo is first day of next month => Subtract one day String dateTo = dateFormat.format(new Date(timeFilterTo - 24L * 3600000L)); diff --git a/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/subscriptions/StatisticsFilterDialog.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/subscriptions/StatisticsFilterDialog.java index 077883321..e46e48240 100644 --- a/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/subscriptions/StatisticsFilterDialog.java +++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/subscriptions/StatisticsFilterDialog.java @@ -2,6 +2,7 @@ package de.danoeh.antennapod.ui.statistics.subscriptions; import android.content.Context; import android.content.SharedPreferences; +import android.text.format.DateFormat; import android.view.LayoutInflater; import android.widget.ArrayAdapter; import com.google.android.material.dialog.MaterialAlertDialogBuilder; @@ -114,7 +115,8 @@ public class StatisticsFilterDialog { date.set(Calendar.DAY_OF_MONTH, 1); ArrayList names = new ArrayList<>(); ArrayList timestamps = new ArrayList<>(); - SimpleDateFormat dateFormat = new SimpleDateFormat("MMM yyyy", Locale.getDefault()); + String skeleton = DateFormat.getBestDateTimePattern(Locale.getDefault(), "MMM yyyy"); + SimpleDateFormat dateFormat = new SimpleDateFormat(skeleton, Locale.getDefault()); while (date.getTimeInMillis() < System.currentTimeMillis()) { names.add(dateFormat.format(new Date(date.getTimeInMillis()))); if (!inclusive) { -- cgit v1.2.3