Use localized date format (#6843)

This commit is contained in:
ByteHamster 2024-01-02 19:21:07 +01:00 committed by GitHub
parent de8bc4ad30
commit b2ea588b54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -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 {

View File

@ -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));

View File

@ -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<String> names = new ArrayList<>();
ArrayList<Long> 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) {