You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/05/06 20:27:01 UTC

[commons-beanutils] 01/02: Remove Java < 1.4 workaround.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-beanutils.git

commit 1536e880242186cd63f4967199c793f9401fbb3d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri May 6 16:13:46 2022 -0400

    Remove Java < 1.4 workaround.
---
 .../converters/DateConverterTestBase.java          | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/src/test/java/org/apache/commons/beanutils2/converters/DateConverterTestBase.java b/src/test/java/org/apache/commons/beanutils2/converters/DateConverterTestBase.java
index 37dcd3ef..f6435fc6 100644
--- a/src/test/java/org/apache/commons/beanutils2/converters/DateConverterTestBase.java
+++ b/src/test/java/org/apache/commons/beanutils2/converters/DateConverterTestBase.java
@@ -62,38 +62,30 @@ public abstract class DateConverterTestBase<T> extends TestCase {
      * @return The time in milliseconds
      */
     long getTimeInMillis(final Object date) {
-
         if (date instanceof java.sql.Timestamp) {
-
-            // N.B. Prior to JDK 1.4 the Timestamp's getTime() method
-            //      didn't include the milliseconds. The following code
-            //      ensures it works consistently across JDK versions
-            final java.sql.Timestamp timestamp = (java.sql.Timestamp)date;
-            long timeInMillis = timestamp.getTime() / 1000 * 1000;
-            timeInMillis += timestamp.getNanos() / 1000000;
-            return timeInMillis;
+            return ((java.sql.Timestamp) date).getTime();
         }
 
         if (date instanceof LocalDate) {
-            return  ((LocalDate)date).atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli();
+            return ((LocalDate) date).atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli();
         }
 
         if (date instanceof LocalDateTime) {
-            return  ((LocalDateTime)date).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
+            return ((LocalDateTime) date).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
         }
 
         if (date instanceof ZonedDateTime) {
-            return  ((ZonedDateTime)date).toInstant().toEpochMilli();
+            return ((ZonedDateTime) date).toInstant().toEpochMilli();
         }
 
         if (date instanceof OffsetDateTime) {
-            return  ((OffsetDateTime)date).toInstant().toEpochMilli();
+            return ((OffsetDateTime) date).toInstant().toEpochMilli();
         }
 
         if (date instanceof Calendar) {
-            return ((Calendar)date).getTime().getTime();
+            return ((Calendar) date).getTime().getTime();
         }
-        return ((Date)date).getTime();
+        return ((Date) date).getTime();
     }
 
     /**