I need to convert the number that corresponds to the day of the week into the String of the day into Java . Ex:
0 => Monday
1 => Tuesday
I need to convert the number that corresponds to the day of the week into the String of the day into Java . Ex:
0 => Monday
1 => Tuesday
You can use DayOfWeek
for this, for example:
import java.time.DayOfWeek;
public class Main {
public static void main (String[] args) {
System.out.println("1 = " + DayOfWeek.of(1));
System.out.println("2 = " + DayOfWeek.of(2));
System.out.println("3 = " + DayOfWeek.of(3));
System.out.println("4 = " + DayOfWeek.of(4));
System.out.println("5 = " + DayOfWeek.of(5));
System.out.println("6 = " + DayOfWeek.of(6));
System.out.println("7 = " + DayOfWeek.of(7));
}
}
See working at repl.it
You can see some more examples: DayOfWeek and Month Enums