Convert to Date before using DateFormat

This commit is contained in:
Niels van Velzen
2022-09-21 19:20:24 +02:00
committed by Niels van Velzen
parent 903d9fa22e
commit 135645ff61
4 changed files with 9 additions and 8 deletions

View File

@@ -18,6 +18,7 @@ import org.jellyfin.androidtv.databinding.ViewCardLegacyImageBinding;
import org.jellyfin.androidtv.ui.AsyncImageView;
import org.jellyfin.androidtv.ui.itemhandling.BaseRowItem;
import org.jellyfin.androidtv.util.ContextExtensionsKt;
import org.jellyfin.androidtv.util.TimeUtils;
import org.jellyfin.androidtv.util.Utils;
import java.text.NumberFormat;
@@ -116,7 +117,7 @@ public class LegacyImageCardView extends BaseCardView {
if (getCardType() == BaseCardView.CARD_TYPE_MAIN_ONLY && item.showCardInfoOverlay()) {
switch (item.getBaseItemType()) {
case PHOTO:
binding.overlayText.setText(item.getBaseItem().getPremiereDate() != null ? android.text.format.DateFormat.getDateFormat(getContext()).format(item.getBaseItem().getPremiereDate()) : item.getFullName(getContext()));
binding.overlayText.setText(item.getBaseItem().getPremiereDate() != null ? android.text.format.DateFormat.getDateFormat(getContext()).format(TimeUtils.getDate(item.getBaseItem().getPremiereDate())) : item.getFullName(getContext()));
binding.icon.setImageResource(R.drawable.ic_camera);
break;
case PHOTO_ALBUM:

View File

@@ -244,11 +244,11 @@ open class BaseRowItem protected constructor(
).joinToString(" - ")
val timestamp = buildString {
append(SimpleDateFormat("d MMM").format(baseItem!!.startDate))
append(SimpleDateFormat("d MMM").format(TimeUtils.getDate(baseItem!!.startDate)))
append(" ")
append((DateFormat.getTimeFormat(context).format(baseItem!!.startDate)))
append((DateFormat.getTimeFormat(context).format(TimeUtils.getDate(baseItem!!.startDate))))
append(" - ")
append(DateFormat.getTimeFormat(context).format(baseItem!!.endDate))
append(DateFormat.getTimeFormat(context).format(TimeUtils.getDate(baseItem!!.endDate)))
}
"$title $timestamp"

View File

@@ -295,8 +295,8 @@ public class InfoLayoutHelper {
case PROGRAM:
case TV_CHANNEL:
if (item.getStartDate() != null && item.getEndDate() != null) {
date.setText(DateFormat.getTimeFormat(context).format(item.getStartDate())
+ "-"+ DateFormat.getTimeFormat(context).format(item.getEndDate()));
date.setText(DateFormat.getTimeFormat(context).format(TimeUtils.getDate(item.getStartDate()))
+ "-"+ DateFormat.getTimeFormat(context).format(TimeUtils.getDate(item.getEndDate())));
layout.addView(date);
addSpacer(context, layout, " ");
}

View File

@@ -71,8 +71,8 @@ fun BaseItemDto.getProgramSubText(context: Context) = buildString {
val dateFormat = DateFormat.getTimeFormat(context)
append(context.getString(
R.string.lbl_time_range,
dateFormat.format(startDate),
dateFormat.format(endDate)
dateFormat.format(TimeUtils.getDate(startDate)),
dateFormat.format(TimeUtils.getDate(endDate))
))
}