-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocalDateTimeMain.java
More file actions
33 lines (23 loc) · 1.17 KB
/
Copy pathLocalDateTimeMain.java
File metadata and controls
33 lines (23 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package time;
import java.time.*;
public class LocalDateTimeMain {
public static void main(String[] args) {
LocalDateTime nowLDT = LocalDateTime.now();
LocalDateTime ofLDT = LocalDateTime.of(2016, 8, 29, 16, 20, 15);
System.out.println("nowLDT = " + nowLDT);
System.out.println("ofLDT = " + ofLDT);
System.out.println();
LocalDate Date = nowLDT.toLocalDate();
LocalTime Time = nowLDT.toLocalTime();
System.out.println("Date = " + Date);
System.out.println("Time = " + Time);
System.out.println();
LocalDateTime ofPlusDays = ofLDT.plusDays(10);
LocalDateTime ofPlusYears = ofLDT.plusYears(30);
System.out.println("ofPlusDays = " + ofPlusDays);
System.out.println("ofPlusYears = " + ofPlusYears);
System.out.println("현재 날짜시간이 지정 날짜시간보다 이전인가?" + nowLDT.isBefore(ofPlusDays));
System.out.println("현재 날짜시간이 지정 날짜시간보다 이후인가?" + nowLDT.isAfter(ofPlusDays));
System.out.println("현재 날짜시간이 지정 날짜시간와 같은가?" + nowLDT.isEqual(ofPlusDays));
}
}