Calendar 클래스

devlsn96·2024년 7월 31일
0

java 언어 개념정리

목록 보기
21/27

Calendar 클래스

Calendar 클래스는 추상클래스이기 때문에, 직접 객체를 생성할 수 없고, 메서드를 통해서 완전히 구현된 클래스의 인스턴스를 얻어야 한다.

캘린더 클래스의 주요 상수값

// 년,월,일,시,분,초
cal.get(Calendar.YEAR);
//자바에서의 월은 0부터 시작된다.
cal.get(Calendar.MONTH) + 1; 
cal.get(Calendar.DAY_OF_MONTH);		
// 24시간제에서의 "시"
cal.get(Calendar.HOUR_OF_DAY);
// 12시간제에서의 "시"
cal.get(Calendar.HOUR);
cal.get(Calendar.MINUTE);
cal.get(Calendar.SECOND);
// 오전(=0), 오후(+1)
Calendar.AM_PM

밀리세컨즈 단위로 현재 시간에 대한 Timestamp얻어보기

cal.getTimeInMillis();, System.currentTimeMillis(); 두가지 방법이 있다.

profile
Quantum Jump to class for java….

0개의 댓글