Skip to content

Commit 4b48890

Browse files
committed
🍱 🔍 ✨
1 parent cc4a320 commit 4b48890

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

javaCodeTest/src/test/java/com/test/datetime/DateTimeTest.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
import org.junit.jupiter.api.Test;
44

5-
import java.time.LocalDate;
6-
import java.time.LocalDateTime;
7-
import java.time.ZoneId;
5+
import java.time.*;
86
import java.time.format.DateTimeFormatter;
97
import java.time.format.DateTimeFormatterBuilder;
108
import java.time.temporal.*;
@@ -22,7 +20,32 @@ public class DateTimeTest {
2220
@Test
2321
void test() {
2422

25-
23+
LocalDateTime now = LocalDateTime.now(ZoneId.systemDefault());
24+
25+
LocalDateTime localDateTime = now.plusDays(1).toLocalDate().atStartOfDay();
26+
27+
System.out.println(localDateTime.format(dateTimeFormatter));
28+
29+
LocalDateTime localDateTime1 = now.toLocalDate().plusDays(1).atTime(LocalTime.MIN);
30+
31+
System.out.println(localDateTime1.format(dateTimeFormatter));
32+
33+
LocalDateTime with = now.with(LocalTime.MAX);
34+
System.out.println(with.format(dateTimeFormatter));
35+
36+
LocalDateTime zonedDateTime = now.toLocalDate().plusDays(1).atStartOfDay();
37+
38+
39+
40+
//long between = ChronoUnit.SECONDS.between(now, zonedDateTime);
41+
42+
LocalDateTime endTime = LocalDateTime.of(2025, 8, 13, 23, 59, 59);
43+
44+
long between = ChronoUnit.SECONDS.between(endTime, zonedDateTime);
45+
46+
System.out.println(between);
47+
48+
2649
}
2750

2851

0 commit comments

Comments
 (0)