long (@NotNull ByteBuffer buffer) { final int first = Byte.toUnsignedInt(buffer.get()); if (first == 0xFF) { return buffer.getLong(); } else { final int second = Byte.toUnsignedInt(buffer.get()); final int third = Byte.toUnsignedInt(buffer.get()) << 16; final int fourth = Byte.toUnsignedInt(buffer.get()) << 8; final int fifth = Byte.toUnsignedInt(buffer.get()); return ((((long)((first << 8) | second)) << 24) | (third | fourth | fifth)) + timeBase; } }