2022 / 9 / 22 목
- Date , Calendar 클래스
- Format 클래스
- java.time 패키지
🔔이클립스 단축키 목록🔔
CTRL + SHIFT + L
✔ Date , Calendar 클래스
Date 클래스
날짜 정보를 표현하는 클래스로 날짜 정보를 객체 간 주고 받을 때 주로 사용된다.
Calendar 클래스
달력을 표현한 추상 클래스
year / month / day / week / amPm / hour / minute / second
✔ Format 클래스
형식(Format) 클래스
숫자와 날짜를 원하는 형식의 문자열로 변환시킨다.
1. 숫자 형식 | DecimalFormat |
2. 날짜 형식 | SimpleDateFormat |
3. 매개변수화 된 문자열 형식 | MessageFormat |
SimpleDateFormat
패턴 | 의미 | 패턴 | 의미 |
y | 년 | H | 0 ~ 23 시 |
M | 월 | h | 1 ~ 12 시 |
d | 일 | K | 0 ~ 11 시 |
D | 월 구분이 없는 일 ( 1~ 365 ) | k | 1 ~ 24 시 |
e | 요일 | m | 분 |
a | 오전 / 오후 | s | 초 |
w | 년의 몇번째 주 | S | 밀리세컨드 ( 1/1000 초) |
W | 월의 몇번째 주 |
➕ SimpleDateFormat 참고하기
https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
SimpleDateFormat (Java Platform SE 7 )
Parses text from a string to produce a Date. The method attempts to parse text starting at the index given by pos. If parsing succeeds, then the index of pos is updated to the index after the last character used (parsing does not necessarily use all charac
docs.oracle.com
✔ java.time 패키지
날짜와 시간을 나타내는 핵심 API인 LocalDate, LocalTime, LocalDateTime, ZoneDateTime을 포함한다.
클래스명 | 의미 |
LocalDate | 로컬 날짜 클래스 |
LocalTime | 로컬 시간 클래스 |
LocalDateTime | 로컬 날짜 및 시간 클래스 ( LocalDate + LocalTime ) |
ZoneDateTime | 특정 타임존(TimeZone)의 날짜와 시간 클래스 |
Instant | 특정 시점의 Time-Stamp 클래스 |
날짜와 시간 조작하기
빼기 : minus + 변수(long)
더하기 : plus + 변수(long)
'🏃♀️ Do it ! > TIL' 카테고리의 다른 글
스레드 상태 / 데몬 스레드 (0) | 2022.09.26 |
---|---|
프로세스 / 스레드 / 동기화 메소드, 동기화 블록 (0) | 2022.09.23 |
String / StringTokenizer / StringBuffer , Builder / 정규표현식 , Pattern / Arrays / Wrapper 클래스 (0) | 2022.09.21 |
예외 처리 / 자바 API / Object 클래스 / class 클래스 / tomcat설치 (0) | 2022.09.20 |
다중 인터페이스 / 디폴트 메서드 / 중첩 클래스 / 익명객체 / 예외 처리 (0) | 2022.09.19 |