https://kotlinlang.org logo
#android
Title
# android
t

Travis Griggs

08/31/2022, 5:06 PM
What is a current/idiomatic way to do the following:
Copy code
listOf("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")
I tried to use
Copy code
DateFormatSymbols().shortWeekdays()
but that surprisingly returns an array of 8 values (so that Sunday can be accessed at 1 apparently). I could slice from 1..7, but that seems hacky. Is there a current idiomatic way to get a list of short weekday names?
c

cd1

09/01/2022, 12:59 PM
I'd use:
Copy code
DayOfWeek.values().map { it.getDisplayName(TextStyle.SHORT, Locale.getDefault()) }
🙏 2
2 Views