Skip to content

Commit edcc217

Browse files
committed
fix: Fixes Date computation.
1 parent 9fdb478 commit edcc217

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/org/ebml/DateElement.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
public class DateElement extends SignedIntegerElement
2626
{
2727
// const uint64 EbmlDate::UnixEpochDelay = 978307200; // 2001/01/01 00:00:00 UTC
28-
public static final long UnixEpochDelay = 978307200; // 2001/01/01 00:00:00 UTC
28+
public static final long UnixEpochDelay = 978307200000L; // 2001/01/01 00:00:00 UTC
2929
private static final int MIN_SIZE_LENGTH = 8;
3030

3131
public DateElement(final byte[] type)
@@ -40,18 +40,18 @@ public DateElement()
4040

4141
/**
4242
* Set the Date of this element
43-
*
43+
*
4444
* @param value Date to set
4545
*/
4646
public void setDate(final Date value)
4747
{
48-
final long val = (value.getTime() - UnixEpochDelay) * 1000000000;
48+
final long val = (value.getTime() - UnixEpochDelay) * 1000000;
4949
setData(ByteBuffer.wrap(packInt(val, MIN_SIZE_LENGTH)));
5050
}
5151

5252
/**
5353
* Get the Date value of this element
54-
*
54+
*
5555
* @return Date of this element
5656
*/
5757
public Date getDate()
@@ -61,7 +61,7 @@ public Date getDate()
6161
* 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);
6262
*/
6363
long val = getValue();
64-
val = val / 1000000000 + UnixEpochDelay;
64+
val = val / 1000000 + UnixEpochDelay;
6565
return new Date(val);
6666
}
6767

0 commit comments

Comments
 (0)