From 0edd4a94c0648002f2c368e087fe94b805303654 Mon Sep 17 00:00:00 2001 From: stevenyomi <95685115+stevenyomi@users.noreply.github.com> Date: Fri, 16 Feb 2024 16:37:30 +0000 Subject: [PATCH] Clean up date format code in docs (#1299) --- CONTRIBUTING.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d9dd971be..db36ff4e1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -423,14 +423,15 @@ will be cached. ```kotlin private fun parseDate(dateStr: String): Long { - return runCatching { DATE_FORMATTER.parse(dateStr)?.time } - .getOrNull() ?: 0L + return try { + dateFormat.parse(dateStr)!!.time + } catch (_: ParseException) { + 0L + } } - companion object { - private val DATE_FORMATTER by lazy { - SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH) - } + private val dateFormat by lazy { + SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH) } ```