-
Notifications
You must be signed in to change notification settings - Fork 0
/
java date and time.java
44 lines (33 loc) · 1.52 KB
/
java date and time.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
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
//Calendar class in Java is an abstract class that provides methods for converting date between a specific instant in time
class Result {
public static String findDay(int month, int day, int year) {
Calendar cal = Calendar.getInstance(); //calender class
cal.set(Calendar.MONTH,month-1); //Set Month
cal.set(Calendar.DAY_OF_MONTH,day); //Set Day
cal.set(Calendar.YEAR,year); //Set Year
String dayOfWeek = cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.US).toUpperCase();
return dayOfWeek;
}
}
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
String[] firstMultipleInput = bufferedReader.readLine().replaceAll("\\s+$", "").split(" ");
int month = Integer.parseInt(firstMultipleInput[0]); //Get Month
int day = Integer.parseInt(firstMultipleInput[1]); //Get Day
int year = Integer.parseInt(firstMultipleInput[2]); //Get Year
String res = Result.findDay(month, day, year);
bufferedWriter.write(res);
bufferedWriter.newLine();
bufferedReader.close();
bufferedWriter.close();
}
}