From f005be1e0b5c9b30555b09671f4e1fc4e4ef8c1a Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Tue, 1 May 2018 18:19:42 -0400 Subject: [PATCH] #1110 - Use default Locale when dealing with dates --- presentation/src/main/java/common/util/DateFormatter.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/presentation/src/main/java/common/util/DateFormatter.kt b/presentation/src/main/java/common/util/DateFormatter.kt index 6bc2c12d..fd939d86 100644 --- a/presentation/src/main/java/common/util/DateFormatter.kt +++ b/presentation/src/main/java/common/util/DateFormatter.kt @@ -37,8 +37,8 @@ class DateFormatter @Inject constructor(val context: Context) { private fun getFormatter(pattern: String): SimpleDateFormat { val isUsing24HourTime = DateFormat.is24HourFormat(context) - return if (isUsing24HourTime) SimpleDateFormat(pattern.replace("h", "HH").replace(" a".toRegex(), ""), Locale.US) - else SimpleDateFormat(pattern, Locale.US) + return if (isUsing24HourTime) SimpleDateFormat(pattern.replace("h", "HH").replace(" a".toRegex(), ""), Locale.getDefault()) + else SimpleDateFormat(pattern, Locale.getDefault()) } fun getTimestamp(date: Long): String { @@ -81,7 +81,7 @@ class DateFormatter @Inject constructor(val context: Context) { } fun parseTime(time: String): Calendar { - val simpleDateFormat = if (time.contains(" ")) getFormatter("h:mm a") else SimpleDateFormat("H:mm", Locale.US) + val simpleDateFormat = if (time.contains(" ")) getFormatter("h:mm a") else SimpleDateFormat("H:mm", Locale.getDefault()) return Calendar.getInstance().apply { this.time = simpleDateFormat.parse(time) } }