fix(android): avoid crash from empty creation time

Fixes COMPOSE-LOBSTERS-17
This commit is contained in:
Harsh Shandilya 2023-07-27 02:57:35 +05:30
parent ed85ba905d
commit b4adfede90
No known key found for this signature in database

View file

@ -31,6 +31,7 @@ import java.io.OutputStream
import java.net.HttpURLConnection
import java.time.LocalDateTime
import java.time.Month
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import javax.inject.Inject
import kotlinx.collections.immutable.ImmutableMap
@ -152,6 +153,7 @@ constructor(
* solution.
*/
private fun String.toLocalDateTime(): LocalDateTime {
if (isEmpty()) return LocalDateTime.now(ZoneId.systemDefault())
return LocalDateTime.from(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(this))
}
}