-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava-Date-and-Time.java
More file actions
46 lines (33 loc) · 1.15 KB
/
Java-Date-and-Time.java
File metadata and controls
46 lines (33 loc) · 1.15 KB
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
43
44
45
class Result {
/*
* Complete the findDay function below.
*
* The function is expected to return a STRING.
* The function accepts following parameters:
* 1. INTEGER month
* 2. INTEGER day
* 3. INTEGER year
*/
public static String findDay(int month, int day, int year) {
//int d = Integer.valueOf(day);
//int m = Integer.valueOf(month);
//int y = Integer.valueOf(year);
//LocalDate date = LocalDate.of(y, m, d);
//return date.getDayOfWeek().toString();
Calendar c = Calendar.getInstance();
c.set(year, month-1, day);
int d = c.get(Calendar.DAY_OF_WEEK);
//System.out.println(d);
switch(d)
{
case 1: return "SUNDAY";
case 2: return "MONDAY";
case 3: return "TUESDAY";
case 4: return "WEDNESDAY";
case 5: return "THURSDAY";
case 6: return "FRIDAY";
case 7: return "SATURDAY";
}
return "";
}
}