@Override
public Instant decode(InputStream inStream) throws CoderException, IOException {
long shiftedMillis;
try {
shiftedMillis = new DataInputStream(inStream).readLong();
} catch (EOFException | UTFDataFormatException exn) {
// These exceptions correspond to decoding problems, so change
// what kind of exception they're branded as.
throw new CoderException(exn);
}
// Produces an {@link Instant} from a {@code long} representing its millis-since-epoch,
// but shifted so that the byte representation of negative values are lexicographically
// ordered before the byte representation of positive values.
//
// This deliberately utilizes the well-defined overflow for {@code long} values.
// See http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.18.2
return new Instant(shiftedMillis + Long.MIN_VALUE);
}
InstantCoder.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:beam
作者:
评论列表
文章目录