Calendar
( 과거 방식입니다. )
( 특징 )
날짜 객체인 Date 의 단점인 날짜 연산 기능을 추가함
정의
싱글톤 패턴 (디자인 패턴)
Calendar now = Calendar.getInstance();
날짜 정보
현재의 날짜 상수들 가져오기
int year = now.get(Calendar.YEAR);
int month = now.get(Calendar.MONTH) + 1;
int week = now.get(Calendar.DAY_OF_WEEK);
int day = now.get(Calendar.DAY_OF_MONTH);
시간정보
현재의 시각 상수들 가져오기
int hour = now.get(Calendar.HOUR);
int minute = now.get(Calendar.MINUTE);
int second = now.get(Calendar.SECOND);
'JAVA' 카테고리의 다른 글
Java - Generic (제네릭) (0) | 2023.09.27 |
---|---|
Java - LocalDate , LocalTime , LocalDateTime (클래스) (0) | 2023.09.26 |
Java - Date (클래스) , SimpleDateFormat (클래스) (0) | 2023.09.26 |
Java - Math (클래스) (0) | 2023.09.26 |
Java - Wrapper ( Boxing , UnBoxing ) (0) | 2023.09.26 |