public static int getNanos(byte[] bytes, int offset) {
    int val = (int) LazyBinaryUtils.readVLongFromByteArray(bytes, offset);
    if (val < 0) {
      val = -val - 1;
    }
    int len = (int) Math.floor(Math.log10(val)) + 1;

    // Reverse the value
    int tmp = 0;
    while (val != 0) {
      tmp *= 10;
      tmp += val % 10;
      val /= 10;
    }
    val = tmp;

    if (len < 9) {
      val *= Math.pow(10, 9 - len);
    }
    return val;
  }
Given an integer representing nanoseconds, write its serialized
value to the byte array b at offset

@param nanos
@param b
@param offset
@return
serde/src/java/org/apache/hadoop/hive/serde2/io/TimestampLocalTZWritable.java