Published:
Updated:

https://programmers.co.kr/learn/courses/30/lessons/12901


Solution

import java.time.LocalDate;

class Solution {
    public static String solution(int a, int b) {
        String answer = "";
        LocalDate date = LocalDate.of(2016, a, b);

        switch (date.getDayOfWeek()) {
            case SUNDAY:
                answer = "SUN";
                break;
            case MONDAY:
                answer = "MON";
                break;
            case TUESDAY:
                answer = "TUE";
                break;
            case WEDNESDAY:
                answer = "WED";
                break;
            case THURSDAY:
                answer = "THU";
                break;
            case FRIDAY:
                answer = "FRI";
                break;
            case SATURDAY:
                answer = "SAT";
                break;
        }

        return answer;
    }

    public static void main(String[] args) {
        System.out.println(solution(5, 24));
    }
}


Another Solution

import java.time.*;
class Solution {
  public String solution(int a, int b) {
      return LocalDate.of(2016, a, b).getDayOfWeek().toString().substring(0,3);
  }
}

Leave a comment