Skip to content

Commit

Permalink
fix: Fixes Date computation.
Browse files Browse the repository at this point in the history
  • Loading branch information
damencho committed Oct 20, 2024
1 parent b7a2dcc commit 3de34a4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/org/ebml/DateElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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);
}

Expand Down

0 comments on commit 3de34a4

Please sign in to comment.