sitelink1 | https://docs.oracle.com/javase/8/docs/ap...lDate.html |
---|---|
sitelink2 | |
sitelink3 | |
sitelink4 | |
sitelink5 | |
sitelink6 |
1. 예제
import java.time.LocalDate;
public class DateTest {
public static void main(String[] args) {
// 1.오늘 날짜 가져오기
LocalDate today = LocalDate.now();
// 2.오늘 날짜(Date) 출력하기
System.out.println(today);
// 3.오늘 날짜 년(Year) 출력하기
System.out.println("올해는 " + today.getYear() + "년입니다.");
// 4.오늘 날짜 월(Month) 출력하기
System.out.println("이번달은 " + today.getMonthValue() + "월입니다.");
// 5.오늘 날짜 일(DayOfMont) 출력하기
System.out.println("오늘은 " + today.getDayOfMonth() + "일입니다.");
// 6.오늘 날짜 요일(DayOfWeek) 출력하기
System.out.println("오늘은 " + today.getDayOfWeek() + "입니다.");
}
}
2. 실행결과
2022-01-16
올해는 2022년입니다.
이번달은 1월입니다.
오늘은 16일입니다.
오늘은 SUNDAY입니다.
3. API
LocalDate (Java Platform SE 8 ) (oracle.com)