Hackerrank Java Date and Time Solution
1 min read

Hackerrank Java Date and Time Solution

Hackerrank Java Date and Time Solution

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.


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.

Sample Input

08 05 2015

Sample Output



The day on August th  was WEDNESDAY.

Solution in java8

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();

Enjoying these posts? Subscribe for more

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

That's okay. But without advertising-income, we can't keep making this site awesome.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add thepoorcoder.com to your ad blocking whitelist or disable your adblocking software.