-
Notifications
You must be signed in to change notification settings - Fork 0
/
java_cal_test.java
99 lines (77 loc) · 2.62 KB
/
java_cal_test.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//Problem: https://www.hackerrank.com/challenges/java-date-and-time/problem
//this makes no sense.
//month is zero indexed?
//this took me 1 hour to understand.
//not in the docs, you oracle soabs
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
import java.lang.*;
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) {
Calendar c = Calendar.getInstance();
System.out.println(month +" "+ day + " "+ year);
String day1 = new String();
c.set(c.MONTH,month);
System.out.println(c.get(c.MONTH) == c.AUGUST);
//c.set(c.DAY_OF_MONTH,day);
//c.set(c.YEAR,year);
c.set(year,month-1,day);
System.out.println(c.getTime());
switch(c.get(c.DAY_OF_WEEK)){
case (Calendar.SUNDAY):
day1 = "SUNDAY";
break;
case (Calendar.MONDAY):
day1 = "MONDAY";
break;
case (Calendar.TUESDAY):
day1 = "TUESDAY";
break;
case (Calendar.WEDNESDAY):
day1 = "WEDNESDAY";
break;
case (Calendar.THURSDAY):
day1 = "THURSDAY";
break;
case (Calendar.FRIDAY):
day1 = "FRIDAY";
break;
case (Calendar.SATURDAY):
day1 = "SATURDAY";
break;
default :
day1 = "LODA";
}
return day1;
}
}
class Solution {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
//BufferedWriter bufferedWriter = new BufferedWriter(new StreamWriter(System.out));
String[] firstMultipleInput = bufferedReader.readLine().replaceAll("\\s+$", "").split(" ");
int month = Integer.parseInt(firstMultipleInput[0]);
int day = Integer.parseInt(firstMultipleInput[1]);
int year = Integer.parseInt(firstMultipleInput[2]);
String res = Result.findDay(month, day, year);
System.out.println(res);
// bufferedWriter.write(res);
// bufferedWriter.newLine();
bufferedReader.close();
// bufferedWriter.close();
}
}