백준 10699 java

magicdrill·2024년 8월 19일
0

백준 문제풀이

목록 보기
421/656

백준 10699 java

오랜만에 Date 클래스를 사용해 보았다. 그런데 SimpleDateFormat을 까먹어서 다른 풀이를 참고했다. 복습에 도움을 받았다.

import java.text.SimpleDateFormat;
import java.util.Date;

public class bj10699 {
    public static void main(String[] args) {
        Date date = new Date();

       /* int year = 1900 + date.getYear();
        int month = 1 + date.getMonth();
        int day = date.getDate();

        System.out.println(year + "-" + month + "-" + day);*/

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        System.out.println(simpleDateFormat.format(date));
    }
}

0개의 댓글