fix: fixed incorrect album release date, hid release date TextView when there is no data

This commit is contained in:
Jaime García 2025-08-07 02:38:17 +02:00
parent bfd6f28d7a
commit 44f8160e21
No known key found for this signature in database
GPG key ID: BC4E5F71A71BDA5B
2 changed files with 19 additions and 7 deletions

View file

@ -14,11 +14,20 @@ open class ItemDate : Parcelable {
var month: Int? = null
var day: Int? = null
fun getFormattedDate(): String {
val calendar = Calendar.getInstance()
val dateFormat = SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault())
fun getFormattedDate(): String? {
if (year == null && month == null && day == null) return null
calendar.set(year ?: 0, month ?: 0, day ?: 0)
val calendar = Calendar.getInstance()
val dateFormat = if (month == null && day == null) {
SimpleDateFormat("yyyy", Locale.getDefault())
} else if (day == null) {
SimpleDateFormat("MMMM yyyy", Locale.getDefault())
}
else{
SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault())
}
calendar.set(year ?: 0, month ?: 1, day ?: 1) // Default to 1 if day is null
return dateFormat.format(calendar.time)
}