Я создаю DateTimeFormatter для форматирования localdate с шаблоном из dateformat.getBestDateTemePattern (..) . Это работает на всех устройствах, которые у нас есть в офисе, но я вижу много аварий в Crashlytics. Мне удалось узнать шаблон, сгенерированный GetBestDateTeMePattern () (d 'de' MMMM) и локаль (spa (ESP)) из сбоев, но эта комбинация работает на всех наших устройствах, так что шаблон/локаль может не быть проблемой. Кто -нибудь столкнулся с этим? < /P>
fun dateTimeFormatterOfBestDateTimePattern(
pattern: String,
locale: Locale = Locale.getDefault()
): DateTimeFormatter {
val datePattern = android.text.format.DateFormat.getBestDateTimePattern(locale, pattern)
return DateTimeFormatter.ofPattern(datePattern)
.withLocale(locale)
.withZone(ZoneId.systemDefault())
}
< /code>
val date = LocalDate.now()
val formatter = dateTimeFormatterOfBestDateTimePattern("MMMMd")
formatter.format(date)
< /code>
Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1
at j$.time.zone.f.i(SourceFile:1107)
at j$.time.format.A.(SourceFile:581)
at j$.time.format.DateTimeFormatter.format(SourceFile:1794)
Подробнее здесь: https://stackoverflow.com/questions/795 ... sexception