Zero-pad 24 hour timestamps

This commit is contained in:
Moez Bhatti
2018-04-04 00:39:25 -04:00
parent f18e766386
commit 0e4e172196
@@ -37,7 +37,7 @@ 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', 'H').replace(" a".toRegex(), ""), Locale.US)
return if (isUsing24HourTime) SimpleDateFormat(pattern.replace("h", "HH").replace(" a".toRegex(), ""), Locale.US)
else SimpleDateFormat(pattern, Locale.US)
}