-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathjava-date-and-time.java
More file actions
35 lines (25 loc) · 1 KB
/
java-date-and-time.java
File metadata and controls
35 lines (25 loc) · 1 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
// Java > Introduction > Java Date and Time
// Print the day of a given date.
//
// https://www.hackerrank.com/challenges/java-date-and-time/problem
// challenge id: 23448
//
import java.util.Scanner;
// (skeliton_head) ----------------------------------------------------------------------
import java.util.*;
public class Solution {
private static String getDay(String day, String month, String year) {
Calendar cal = Calendar.getInstance();
cal.set(Integer.parseInt(year), Integer.parseInt(month) - 1, Integer.parseInt(day));
String s = cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.US);
return s.toUpperCase();
}
// (skeliton_tail) ----------------------------------------------------------------------
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String month = in.next();
String day = in.next();
String year = in.next();
System.out.println(getDay(day, month, year));
}
}