Is there an inverse function of DayOfWeek::getDisplayName()

Viewed 146

I need a converter that converts DayOfWeek into String and the other way around given some Locale and TextStyle. One way is straight forward:

public String getAsString(DayOfWeek day, TextStyle style, Locale locale){
    return day.getDisplayName(style, locale);
}

For the other way I did not find any useful methods in the java.time package. I'm looking for something like LocalDate::parse(CharSequence text, DateTimeFormatter formatter) but for DayOfWeek.

1 Answers
Related