Input Format

A single line of input containing the space separated month, day and year, respectively, in    format.


Output Format

Output the correct day in capital letters.

hackerrank java date and time solution

Java Date and Time problem solution | HackerRank

import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.Scanner;

public class JavaDateAndTime {
    static List<String> days = Arrays.asList("SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY");
    public static String getDay(String day, String month, String year) {
        int y = Integer.parseInt(year);
        int m = Integer.parseInt(month);
        int d = Integer.parseInt(day);
        Calendar c = Calendar.getInstance();
        c.set(y, m-1, d); 
        int p = c.get(Calendar.DAY_OF_WEEK);
        String s = days.get(p-1);
        return s;
    public static void main(String[] args) {
        Scanner in = new Scanner(;
        String month =;
        String day =;
        String year =;
        System.out.println(getDay(day, month, year));