<NME> DateUtils.kt
<BEF> /*
 * This file is part of Blokada.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 *
 * Copyright © 2021 Blocka AB. All rights reserved.
 *
 * @author Karol Gusak (karol@blocka.net)
 */

package utils

import java.text.SimpleDateFormat
import java.util.*

val blockaDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ"
val blockaDateFormatShort = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
val blockaDateFormatNoNanos = "yyyy-MM-dd'T'HH:mm:ss'Z'"

val userDateFormatSimple = "d MMMM yyyy"
val userDateFormatFull = "yyyyMMd jms"
val userDateFormatChat = "E., MMd, jms"

private val simpleFormat = SimpleDateFormat(userDateFormatSimple).apply {
    timeZone = TimeZone.getTimeZone("GMT")
}
private val blockaFormat = SimpleDateFormat(blockaDateFormat).apply {
    timeZone = TimeZone.getTimeZone("GMT")
}
private val blockaFormat2 = SimpleDateFormat(blockaDateFormatShort).apply {
    timeZone = TimeZone.getTimeZone("GMT")
}

private val blockaFormat3 = SimpleDateFormat(blockaDateFormatNoNanos).apply {
    timeZone = TimeZone.getTimeZone("GMT")
}

fun Date.toSimpleString(): String {
    return simpleFormat.format(this)
}

fun String.toBlockaDate(): Date {
    return blockaFormat.runCatching { parse(this@toBlockaDate) }.getOrNull() ?:
    blockaFormat2.runCatching { parse(this@toBlockaDate) }.getOrNull() ?:
    blockaFormat3.runCatching { parse(this@toBlockaDate) }.getOrThrow()
}
<MSG> android: fix strange date string formatting

<DFF> @@ -12,6 +12,7 @@
 
 package utils
 
+import java.text.DateFormat
 import java.text.SimpleDateFormat
 import java.util.*
 
@@ -19,11 +20,7 @@ val blockaDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ"
 val blockaDateFormatShort = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
 val blockaDateFormatNoNanos = "yyyy-MM-dd'T'HH:mm:ss'Z'"
 
-val userDateFormatSimple = "d MMMM yyyy"
-val userDateFormatFull = "yyyyMMd jms"
-val userDateFormatChat = "E., MMd, jms"
-
-private val simpleFormat = SimpleDateFormat(userDateFormatSimple).apply {
+private val simpleFormat = DateFormat.getDateInstance(DateFormat.LONG, Locale.US).apply {
     timeZone = TimeZone.getTimeZone("GMT")
 }
 private val blockaFormat = SimpleDateFormat(blockaDateFormat).apply {

{'commit': 'diff --git a/android5/app/src/main/java/utils/DateUtils.kt b/android5/app/src/main/java/utils/DateUtils.kt\nindex eac194e3..081747ac 100644\n--- a/android5/app/src/main/java/utils/DateUtils.kt\n+++ b/android5/app/src/main/java/utils/DateUtils.kt\n@@ -12,6 +12,7 @@\n \n package utils\n \n+import java.text.DateFormat\n import java.text.SimpleDateFormat\n import java.util.*\n \n@@ -19,11 +20,7 @@ val blockaDateFormat = "yyyy-MM-dd\'T\'HH:mm:ss.SSSSSSZ"\n val blockaDateFormatShort = "yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'"\n val blockaDateFormatNoNanos = "yyyy-MM-dd\'T\'HH:mm:ss\'Z\'"\n \n-val userDateFormatSimple = "d MMMM yyyy"\n-val userDateFormatFull = "yyyyMMd jms"\n-val userDateFormatChat = "E., MMd, jms"\n-\n-private val simpleFormat = SimpleDateFormat(userDateFormatSimple).apply {\n+private val simpleFormat = DateFormat.getDateInstance(DateFormat.LONG, Locale.US).apply {\n     timeZone = TimeZone.getTimeZone("GMT")\n }\n private val blockaFormat = SimpleDateFormat(blockaDateFormat).apply {\n', 'commit_subject': 'android: fix strange date string formatting', 'repo_name': 'blokadaorg/blokada', 'committer': {'name': 'kar', 'email': 'c22b5f9178342609428d6f51b2c5af4c0bde6a42@kar.gs', 'time_sec': '1658917532', 'tz_offset': '120', 'date': {'seconds': '1658917532'}}, 'commit_tree': '093792c814479d4f2e9860871ecc59f0e5356546', 'commit_message': 'android: fix strange date string formatting\n', 'language_name': 'C', 'license': 'mpl-2.0', 'hunks': '@@ -12,6 +12,7 @@\n \n package utils\n \n+import java.text.DateFormat\n import java.text.SimpleDateFormat\n import java.util.*\n \n@@ -19,11 +20,7 @@ val blockaDateFormat = "yyyy-MM-dd\'T\'HH:mm:ss.SSSSSSZ"\n val blockaDateFormatShort = "yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'"\n val blockaDateFormatNoNanos = "yyyy-MM-dd\'T\'HH:mm:ss\'Z\'"\n \n-val userDateFormatSimple = "d MMMM yyyy"\n-val userDateFormatFull = "yyyyMMd jms"\n-val userDateFormatChat = "E., MMd, jms"\n-\n-private val simpleFormat = SimpleDateFormat(userDateFormatSimple).apply {\n+private val simpleFormat = DateFormat.getDateInstance(DateFormat.LONG, Locale.US).apply {\n     timeZone = TimeZone.getTimeZone("GMT")\n }\n private val blockaFormat = SimpleDateFormat(blockaDateFormat).apply {\n', 'addition_count': 2, 'deletion_count': 5, 'src_file': 'a/android5/app/src/main/java/utils/DateUtils.kt', 'tgt_file': 'b/android5/app/src/main/java/utils/DateUtils.kt', 'file_extension': '.kt', 'before_file': '/*\n * This file is part of Blokada.\n *\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n *\n * Copyright © 2021 Blocka AB. All rights reserved.\n *\n * @author Karol Gusak (karol@blocka.net)\n */\n\npackage utils\n\nimport java.text.SimpleDateFormat\nimport java.util.*\n\nval blockaDateFormat = "yyyy-MM-dd\'T\'HH:mm:ss.SSSSSSZ"\nval blockaDateFormatShort = "yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'"\nval blockaDateFormatNoNanos = "yyyy-MM-dd\'T\'HH:mm:ss\'Z\'"\n\nval userDateFormatSimple = "d MMMM yyyy"\nval userDateFormatFull = "yyyyMMd jms"\nval userDateFormatChat = "E., MMd, jms"\n\nprivate val simpleFormat = SimpleDateFormat(userDateFormatSimple).apply {\n    timeZone = TimeZone.getTimeZone("GMT")\n}\nprivate val blockaFormat = SimpleDateFormat(blockaDateFormat).apply {\n    timeZone = TimeZone.getTimeZone("GMT")\n}\nprivate val blockaFormat2 = SimpleDateFormat(blockaDateFormatShort).apply {\n    timeZone = TimeZone.getTimeZone("GMT")\n}\n\nprivate val blockaFormat3 = SimpleDateFormat(blockaDateFormatNoNanos).apply {\n    timeZone = TimeZone.getTimeZone("GMT")\n}\n\nfun Date.toSimpleString(): String {\n    return simpleFormat.format(this)\n}\n\nfun String.toBlockaDate(): Date {\n    return blockaFormat.runCatching { parse(this@toBlockaDate) }.getOrNull() ?:\n    blockaFormat2.runCatching { parse(this@toBlockaDate) }.getOrNull() ?:\n    blockaFormat3.runCatching { parse(this@toBlockaDate) }.getOrThrow()\n}', 'message': 'android: fix strange date string formatting\n', 'author_name': 'kar', 'lang': 'kt'}