Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DateUTC computation #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 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 @@ -45,7 +45,7 @@ public DateElement()
*/
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)));
}

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