Код: Выделить всё
Timber.d("test delta, departed = $time1, plan = $time2")
val deltaMills = time1.time - time2.time
val sign = if (deltaMills < 0) "-" else if (deltaMills > 0) "+" else ""
val pattern = if (Calendar.getInstance().fromDate(it).get(Calendar.HOUR_OF_DAY) == 0) "m" else "H:mm"
val result = "$sign${SimpleDateFormat(pattern, Locale.getDefault()).format(Date(deltaMills.absoluteValue))}"
Код: Выделить всё
test delta, departed = Fri Feb 21 14:00:01 GMT+01:00 2025, plan = Fri Feb 21 10:01:48 GMT+01:00 2025
Ожидаемое: +3: 58
Фактическое: + 4:58
Подробнее здесь: https://stackoverflow.com/questions/794 ... using-date