We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dc5001b commit 0a27016Copy full SHA for 0a27016
persistence-modules/java-jpa/src/test/java/com/baeldung/jpa/convertdates/LocalDateTimeToSqlDateUnitTest.java
@@ -0,0 +1,21 @@
1
+package com.baeldung.jpa.convertdates;
2
+
3
+import static org.assertj.core.api.Assertions.assertThat;
4
5
+import java.time.LocalDateTime;
6
7
+import org.junit.jupiter.api.Test;
8
9
+class LocalDateTimeToSqlDateUnitTest {
10
11
+ @Test
12
+ void givenALocalDateTime_whenConvertingToSqlDate_thenReturnSqlDateWithoutTime() {
13
+ LocalDateTime givenLocalDateTime = LocalDateTime.parse("2024-05-06T14:02:22.214");
14
+ java.sql.Date expectedSqlDate = java.sql.Date.valueOf("2024-05-06");
15
16
+ java.sql.Date sqlDate = java.sql.Date.valueOf(givenLocalDateTime.toLocalDate());
17
18
+ assertThat(sqlDate).isEqualTo(expectedSqlDate);
19
+ }
20
21
+}
0 commit comments