Add a small check in the time parser to ignore malformed date.

This commit is contained in:
Thomas Andres Gomez 2024-01-22 18:36:11 +01:00
parent 6ef8684b59
commit f4a381fb02

View file

@ -9,6 +9,12 @@ class TimeUpdateParser @Inject constructor() {
private val formatter = SimpleDateFormat(BuildConfig.TIME_FORMAT, Locale.FRANCE)
fun parser(value: String?): Long? {
return value?.let { formatter.parse(it) }?.time
return value?.let {
try {
formatter.parse(it)
} catch (_: Exception) {
null
}
}?.time
}
}