code: public static long decodeTimestamp(long seconds, long serializedNanos, long baseTimestampInSeconds)
      {
          long millis = (seconds + baseTimestampInSeconds) * MILLIS_PER_SECOND;
          long nanos = parseNanos(serializedNanos);
          if (nanos > 999999999 || nanos < 0) {
              throw new IllegalArgumentException("nanos field of an encoded timestamp in ORC must be between 0 and 999999999 inclusive, got " + nanos);
          }
  
          // the rounding error exists because java always rounds up when dividing integers
          // -42001/1000 = -42; and -42001 % 1000 = -1 (+ 1000)
          // to get the correct value we need
          // (-42 - 1)*1000 + 999 = -42001
          // (42)*1000 + 1 = 42001
          if (millis < 0 && nanos != 0) {
              millis -= 1000;
          }
          // Truncate nanos to millis and add to mills
          return millis + (nanos / 1_000_000);
      }
docs: This comes from the Apache Hive ORC code