Skip to content
the poor coder

Hackerrank Java Date and Time Solution

Poor Man
Published
Updated
Reading time
1 min read

The Calendar class is an abstract class that provides methods for converting between a specific instant in time and a set of calendar fields such as YEAR, MONTH, DAY_OF_MONTH, HOUR, and so on, and for manipulating the calendar fields, such as getting the date of the next week.


You are given a date. You just need to write the method, , which returns the day on that date.  To simplify your task, we have provided a portion of the code in the editor.

For example, if you are given the date , the method should return  as the day on that date.

image

Input Format

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

Constraints

Output Format

Output the correct day in capital letters.

Sample Input

Text
08 05 2015

Sample Output

Text
WEDNESDAY

Explanation

The day on August th  was WEDNESDAY.

Solution in java8#

Python
import java.time.LocalDate;
class Result {
    public static String findDay(int month, int day, int year) {
        LocalDate dt = LocalDate.of(year, month, day);
        return ""+dt.getDayOfWeek();
    }
}

Keep going

2020

Hackerrank Java Datatypes Solution

Java has 8 primitive data types; char, boolean, byte, short, int, long, float, and double. For this exercise, we'll work with the primitives used to hold integer values (byte, short, int, and long): A byte is an 8-bit…

ESC