알고리즘 풀이

Level 2 2016년

bedst 2017. 3. 30. 17:39

/*

 * 2016년 요일을 받아서 날짜 구하기

 * 출처 : http://tryhelloworld.co.kr/challenge_codes/176

 */

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Scanner;


class TryHelloWorld000

{

    public String getDayName(int a, int b) throws ParseException{

        String answer = "";

        

SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");

Scanner sc = new Scanner(System.in);

a = sc.nextInt();

b = sc.nextInt();

Date date = formatter.parse("20160"+a+b);

date = new Date(date.getTime());

answer = date.toString().substring(0, 3);


        

        return answer;

    }

    public static void main(String[] args) throws ParseException

    {

        TryHelloWorld000 test = new TryHelloWorld000();

        int a=5, b=24;

        System.out.println(test.getDayName(a,b));

    }

}