Add seconds display for absolute time same day format

This commit is contained in:
kyori19 2022-05-05 16:22:56 +09:00
parent d43f01920b
commit 3e9903b330
1 changed files with 4 additions and 4 deletions

View File

@ -22,10 +22,10 @@ import java.util.Locale
import java.util.TimeZone import java.util.TimeZone
class AbsoluteTimeFormatter @JvmOverloads constructor(private val tz: TimeZone = TimeZone.getDefault()) { class AbsoluteTimeFormatter @JvmOverloads constructor(private val tz: TimeZone = TimeZone.getDefault()) {
private val sameDaySdf = SimpleDateFormat("HH:mm", Locale.getDefault()).apply { this.timeZone = tz } private val sameDaySdf = SimpleDateFormat("HH:mm:ss", Locale.getDefault()).apply { this.timeZone = tz }
private val sameYearSdf = SimpleDateFormat("MM-dd HH:mm", Locale.getDefault()).apply { this.timeZone = tz } private val sameYearSdf = SimpleDateFormat("MM/dd HH:mm", Locale.getDefault()).apply { this.timeZone = tz }
private val otherYearSdf = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).apply { this.timeZone = tz } private val otherYearSdf = SimpleDateFormat("yyyy/MM/dd", Locale.getDefault()).apply { this.timeZone = tz }
private val otherYearCompleteSdf = SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()).apply { this.timeZone = tz } private val otherYearCompleteSdf = SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.getDefault()).apply { this.timeZone = tz }
@JvmOverloads @JvmOverloads
fun format(time: Date?, shortFormat: Boolean = true, now: Date = Date()): String { fun format(time: Date?, shortFormat: Boolean = true, now: Date = Date()): String {