From b2ea588b5479c7e1aa0b40932c9734f5389258db Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Tue, 2 Jan 2024 19:21:07 +0100 Subject: [PATCH] Use localized date format (#6843) --- .../main/java/de/danoeh/antennapod/ui/echo/EchoActivity.java | 4 +++- .../subscriptions/PlaybackStatisticsListAdapter.java | 4 +++- .../ui/statistics/subscriptions/StatisticsFilterDialog.java | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/EchoActivity.java b/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/EchoActivity.java index 7bf3a75d0..2989cc748 100644 --- a/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/EchoActivity.java +++ b/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/EchoActivity.java @@ -10,6 +10,7 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; +import android.text.format.DateFormat; import android.util.Log; import android.util.Pair; import android.view.KeyEvent; @@ -272,7 +273,8 @@ public class EchoActivity extends AppCompatActivity { viewBinding.aboveLabel.setText(""); viewBinding.largeLabel.setText(R.string.echo_thanks_large); if (oldestDate < jan1()) { - SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM yyyy", getEchoLanguage()); + String skeleton = DateFormat.getBestDateTimePattern(getEchoLanguage(), "MMMM yyyy"); + SimpleDateFormat dateFormat = new SimpleDateFormat(skeleton, getEchoLanguage()); String dateFrom = dateFormat.format(new Date(oldestDate)); viewBinding.belowLabel.setText(getString(R.string.echo_thanks_we_are_glad_old, dateFrom)); } else { 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) {