Date의 단점을 해결하기 위해 나온 클래스
import java.util.Calendar;
Calendar cal = Calendar.getInstance();
System.out.println(cal.get(Calendar.YEAR));
System.out.println(cal.get(Calendar.MONTH)+1); // 1월 ~ 12월이 0 ~ 11로 표현된다
System.out.println(cal.get(Calendar.DATE));
System.out.println(cal.get(Calendar.HOUR));
System.out.println(cal.get(Calendar.HOUR_OF_DAY));
System.out.println(cal.get(Calendar.MINUTE));
System.out.println(cal.get(Calendar.SECOND));
출력값
2022
1
26
1
13
17
5
Calendar cal = Calendar.getInstance();
System.out.println(cal.get(Calendar.HOUR));
cal.add(Calendar.HOUR, 5); // cal 에 5시간을 더해준다
System.out.println(cal.get(Calendar.HOUR));
출력값
1
6