From 03825846d474da5adfa7efa2148480e94d97e089 Mon Sep 17 00:00:00 2001 From: damencho Date: Sat, 19 Oct 2024 20:50:09 -0500 Subject: [PATCH] fix: Fixes Date computation. --- src/main/java/org/ebml/DateElement.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/ebml/DateElement.java b/src/main/java/org/ebml/DateElement.java index 72d0753..77de5ca 100644 --- a/src/main/java/org/ebml/DateElement.java +++ b/src/main/java/org/ebml/DateElement.java @@ -25,7 +25,7 @@ public class DateElement extends SignedIntegerElement { // const uint64 EbmlDate::UnixEpochDelay = 978307200; // 2001/01/01 00:00:00 UTC - public static final long UnixEpochDelay = 978307200; // 2001/01/01 00:00:00 UTC + public static final long UnixEpochDelay = 978307200000L; // 2001/01/01 00:00:00 UTC private static final int MIN_SIZE_LENGTH = 8; public DateElement(final byte[] type) @@ -40,18 +40,18 @@ public DateElement() /** * Set the Date of this element - * + * * @param value Date to set */ public void setDate(final Date value) { - final long val = (value.getTime() - UnixEpochDelay) * 1000000000; + final long val = (value.getTime() - UnixEpochDelay) * 1000000; setData(ByteBuffer.wrap(packInt(val, MIN_SIZE_LENGTH))); } /** * Get the Date value of this element - * + * * @return Date of this element */ public Date getDate() @@ -61,7 +61,7 @@ public Date getDate() * long diff1 = start.getTime(); long diff2 = end.getTime(); long diff3 = Date.UTC(2001, 1, 1, 0, 0, 0) - Date.UTC(1970, 1, 1, 0, 0, 0); */ long val = getValue(); - val = val / 1000000000 + UnixEpochDelay; + val = val / 1000000 + UnixEpochDelay; return new Date(val); }