ppkarwasz commented on code in PR #1385:
URL: https://github.com/apache/commons-lang/pull/1385#discussion_r2094467405


##########
src/main/java/org/apache/commons/lang3/time/DateUtils.java:
##########
@@ -1625,6 +1628,34 @@ public static Calendar toCalendar(final Date date, final 
TimeZone tz) {
         return c;
     }
 
+    /**
+     * Converts a {@link Date} into a {@link LocalDateTime}, using the default 
time zone.
+     * @param date the date to convert to a LocalDateTime
+     * @return the created LocalDateTime
+     * @throws NullPointerException if {@code date} is null
+     * @since 3.18
+     */
+    public static LocalDateTime toLocalDateTime(final Date date) {
+        return toLocalDateTime(date, TimeZone.getDefault());
+    }
+
+    /**
+     * Converts a {@link Date} into a {@link LocalDateTime}
+     * @param date the date to convert to a LocalDateTime
+     * @param tz the time zone of the {@code date}
+     * @return the created LocalDateTime
+     * @throws NullPointerException if {@code date} is null
+     * @since 3.18
+     */
+    public static LocalDateTime toLocalDateTime(final Date date, final 
TimeZone tz) {
+        final LocalDateTime localDateTime = 
LocalDateTime.ofInstant(Instant.ofEpochMilli(Objects.requireNonNull(date, 
"date").getTime()),
+                Objects.requireNonNull(tz, "tz").toZoneId());
+        if (date instanceof java.sql.Timestamp) {

Review Comment:
   Fixed in 
https://github.com/apache/commons-lang/pull/1385/commits/7d1692cf3c290d94a81267cdc6cd1d4938f1ac79,
 but the solution creates an open problem with the Moditect Maven Plugin. See 
https://github.com/apache/commons-lang/pull/1385#discussion_r2094456368 below.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to