-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDayOfWeekInWords.java
42 lines (38 loc) · 1.23 KB
/
DayOfWeekInWords.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.Calendar;
import java.text.SimpleDateFormat;
public class DayOfWeekInWords
{
public static void main(String[] args)
{
Calendar calendar = Calendar.getInstance();
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
String dayOfWeekInWords;
switch (dayOfWeek) {
case Calendar.SUNDAY:
dayOfWeekInWords = "Sunday";
break;
case Calendar.MONDAY:
dayOfWeekInWords = "Monday";
break;
case Calendar.TUESDAY:
dayOfWeekInWords = "Tuesday";
break;
case Calendar.WEDNESDAY:
dayOfWeekInWords = "Wednesday";
break;
case Calendar.THURSDAY:
dayOfWeekInWords = "Thursday";
break;
case Calendar.FRIDAY:
dayOfWeekInWords = "Friday";
break;
case Calendar.SATURDAY:
dayOfWeekInWords = "Saturday";
break;
default:
dayOfWeekInWords = "Invalid day";
break;
}
System.out.println("Day of the week: " + dayOfWeekInWords);
}
}