2

Why is it that whenever I set a DayOfWeek for my TextView the output always appears in capital letters? Also, the day never changes when the language of my device is changed. How can it be set to change based on the device's current locale?

    myTv.text = DayOfWeek.MONDAY.toString()

Output

MONDAY
XBlueCode
  • 785
  • 3
  • 18
wbk727
  • 8,017
  • 12
  • 61
  • 125
  • 2
    You are `toString`-ing the enum. So you get back the name of the enum itself. That is not the display-name. You get that by using `getDisplayName`. Also see the official documentation: https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/time/DayOfWeek.html. – Zabuzard Sep 13 '19 at 12:06

1 Answers1

8

You could do (replace Locale accordingly...)

String day = DayOfWeek.MONDAY.getDisplayName(TextStyle.FULL, Locale.getDefault());
Reimeus
  • 158,255
  • 15
  • 216
  • 276