프로그래머스 - 2016년
Contents
Date 오브젝트 쓰기!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class TryHelloWorld { public String getDayName(int a, int b) { String answer = ""; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf2 = new SimpleDateFormat("E"); String dateInString = "2016-"+a+"-"+b; Date date; try { date = sdf.parse(dateInString); answer = sdf2.format(date).toUpperCase(); } catch (ParseException e) { } return answer; } public static void main(String[] args) { TryHelloWorld test = new TryHelloWorld(); int a=5, b=24; System.out.println(test.getDayName(a,b)); } } |
Author Jaejin Jang
LastMod 2017-12-23
License Jaejin Jang