I have date strings in a given matching format: 2017-03-25T11:24:20 or 2020-06-26T11:14:00
and would like to find which day of the week is on a given date, usin java or Kotlin
I have date strings in a given matching format: 2017-03-25T11:24:20 or 2020-06-26T11:14:00
and would like to find which day of the week is on a given date, usin java or Kotlin
You can parse the datetime string to LocalDateTime
object and use its getDayOfWeek()
method (doc) to find the day of week, which returns a DayOfWeek
enum (doc). In Kotlin, it would look like
val date = LocalDateTime.parse("2017-03-25T11:24:20")
println(date.dayOfWeek) // would print "SATURDAY"
On the DayOfWeek
enum, you could use getDisplayName(TextStyle style, Locale locale)
to get a localized textual representation, such as 'Mon' or 'Friday', or getValue()
to get the day-of-week int value.