- Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathjava-date-and-time.java
More file actions
Latest commit
35 lines (25 loc) · 1 KB
/
Copy pathjava-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
//
importjava.util.Scanner;
// (skeliton_head) ----------------------------------------------------------------------
importjava.util.*;
publicclassSolution {
privatestaticStringgetDay(Stringday, Stringmonth, Stringyear) {
Calendarcal = Calendar.getInstance();
cal.set(Integer.parseInt(year), Integer.parseInt(month) - 1, Integer.parseInt(day));
Strings = cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.US);
returns.toUpperCase();
}
// (skeliton_tail) ----------------------------------------------------------------------
publicstaticvoidmain(String[] args) {
Scannerin = newScanner(System.in);
Stringmonth = in.next();
Stringday = in.next();
Stringyear = in.next();
System.out.println(getDay(day, month, year));
}
}