Java/ref.

ref. Calendar Class

pancakemaker 2021. 10. 27. 11:10

Calendar now = Calendar.getInstance() : 현재 날짜를 변수 now에 저장한다.

get 메소드 활용하여 다음과 같이 얻을 수 있다.

 

int year = now.get(Calendar.YEAR); //년

int month = now.get(Calendar.MONTH) + 1; //월(1~12)

int day = now.get(Calendar.DAY_OF_MONTH); //일

int week = now.get(Calendar.DAY_OF_WEEK); //요일(1~7)

int hour = now.get(Calendar.HOUR); //시간

int minute = now.get(Calendar.MINUTE); //분

int second = now.get(Calendar.SECOND); //초