You are viewing a single comment's thread. Return to all comments →
Use LocalDate (available in Java 8 but not Java 7) instead of Calendar. It's simpler.
import java.util.Scanner; import java.time.LocalDate; public class Solution { public static void main(String[] args) { /* Read input */ Scanner scan = new Scanner(System.in); int month = scan.nextInt(); int day = scan.nextInt(); int year = scan.nextInt(); scan.close(); /* Create LocalDate instance */ LocalDate date = LocalDate.of(year, month, day); System.out.println(date.getDayOfWeek()); } }
From my HackerRank Java solutions.
Seems like cookies are disabled on this browser, please enable them to open this website
Java Date and Time
You are viewing a single comment's thread. Return to all comments →
Java solution - passes 100% of test cases
Use LocalDate (available in Java 8 but not Java 7) instead of Calendar. It's simpler.
From my HackerRank Java solutions.