Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove unpackTimestampMillis
  • Loading branch information
xerial committed May 11, 2021
commit ad6fb2de9433c585cd6c9e998a19b08503c68726
35 changes: 3 additions & 32 deletions msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ public Instant unpackTimestamp()
}
switch (ext.getLength()) {
case 4: {
int u32 = readInt();
long u32 = readInt() & 0xffffffffL;
return Instant.ofEpochSecond(u32);
}
case 8: {
Expand All @@ -1289,38 +1289,9 @@ public Instant unpackTimestamp()
return Instant.ofEpochSecond(sec, nsec);
}
case 12: {
int nsec = readInt();
long sec = readLong();
return Instant.ofEpochSecond(sec, nsec);
}
default:
throw new MessageFormatException(String.format("Timestamp extension type (%d) expects 4, 8, or 12 bytes of payload but got %d bytes",
EXT_TIMESTAMP, ext.getLength()));
}
}

public long unpackTimestampMillis()
throws IOException
{
ExtensionTypeHeader ext = unpackExtensionTypeHeader();
if (ext.getType() != EXT_TIMESTAMP) {
throw unexpectedExtension("Timestamp", EXT_TIMESTAMP, ext.getType());
}
switch (ext.getLength()) {
case 4: {
int u32 = readInt();
return (u32 & 0xffffffffL) * 1000L;
}
case 8: {
long data64 = readLong();
int nsec = (int) (data64 >>> 34);
long sec = data64 & 0x00000003ffffffffL;
return sec * 1000L + nsec / 1000L;
}
case 12: {
int nsec = readInt();
long nsecU32 = readInt() & 0xffffffffL;
long sec = readLong();
return sec * 1000L + nsec / 1000L;
return Instant.ofEpochSecond(sec, nsecU32);
}
default:
throw new MessageFormatException(String.format("Timestamp extension type (%d) expects 4, 8, or 12 bytes of payload but got %d bytes",
Expand Down