Returns GMT timestamp from binary encoded parquet timestamp (12 bytes - julian date + time of day nanos).

@param timestampBinary INT96 parquet timestamp
@return timestamp in millis, GMT timezone
499315
public static long getTimestampMillis(Binary timestampBinary) {
    if (timestampBinary.length() != BYTES_IN_INT96_TIMESTAMP) {
      throw new IllegalArgumentException("Parquet timestamp must be 12 bytes long, actual " + timestampBinary.length());
    }
    byte[] bytes = timestampBinary.getBytes();

    // little endian encoding - bytes are red in inverted order
    long timeOfDayNanos = TypeUtils.longFromBytes(bytes[7], bytes[6], bytes[5], bytes[4], bytes[3], bytes[2], bytes[1], bytes[0]);
    int julianDay = TypeUtils.intFromBytes(bytes[11], bytes[10], bytes[9], bytes[8]);

    return julianDayToMillis(julianDay) + (timeOfDayNanos / NANOS_PER_MILLISECOND);
  }
1258634
private static long getRawTimestamp(long timeMillis) {
        checkArgument(timeMillis >= TIME_MILLIS_MIN, "Time value too small.");  // < 12am Oct 15, 1582 (UTC)
        checkArgument(timeMillis <= TIME_MILLIS_MAX, "Time value too large.");  // > 9:21pm Mar 31, 5236 (UTC)
        return timeMillis * 10000 + NUM_100NS_INTERVALS_SINCE_UUID_EPOCH;
    }
436985
public static ZonedDateTime getZonedDataTime(long timestamp,
            String zoneId) {
        return Instant.ofEpochMilli(timestamp).atZone(getZoneId(zoneId));
    }
877005
def get_timestamp(timezone_name, year, month, day, hour=0, minute=0):
    """"""
    tz = pytz.timezone(timezone_name)
    tz_datetime = tz.localize(datetime(year, month, day, hour, minute))
    timestamp = calendar.timegm(tz_datetime.utctimetuple())
    return timestamp
661494
public void writeBinary(final PacketOutputStream pos) throws IOException {
    Calendar calendar = Calendar.getInstance(timeZone);
    calendar.setTime(time);
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    if (fractionalSeconds) {
      pos.write((byte) 12);
      pos.write((byte) 0);
      pos.writeInt(0);
      pos.write((byte) calendar.get(Calendar.HOUR_OF_DAY));
      pos.write((byte) calendar.get(Calendar.MINUTE));
      pos.write((byte) calendar.get(Calendar.SECOND));
      pos.writeInt(calendar.get(Calendar.MILLISECOND) * 1000);
    } else {
      pos.write((byte) 8);//length
      pos.write((byte) 0);
      pos.writeInt(0);
      pos.write((byte) calendar.get(Calendar.HOUR_OF_DAY));
      pos.write((byte) calendar.get(Calendar.MINUTE));
      pos.write((byte) calendar.get(Calendar.SECOND));
    }
  }
1287352
def utcfromtimestamp(cls, t):
        ""
        t, frac = divmod(t, 1.0)
        us = int(frac * 1e6)

        # If timestamp is less than one microsecond smaller than a
        # full second, us can be rounded up to 1000000.  In this case,
        # roll over to seconds, otherwise, ValueError is raised
        # by the constructor.
        if us == 1000000:
            t += 1
            us = 0
        y, m, d, hh, mm, ss, weekday, jday, dst = _time.gmtime(t)
        ss = min(ss, 59)    # clamp out leap seconds if the platform has them
        return cls(y, m, d, hh, mm, ss, us)
879622
static public TimestampType decodeTimestamp(final ByteBuffer bb) {
        final Long val = bb.getLong();
        return new TimestampType(val);
    }
1103210
synchronized TimeData getCurrentTime(boolean withZone) {

        resetCurrentTimestamp();

        if (withZone) {
            if (currentTime == null) {
                int seconds =
                    (int) (HsqlDateTime.getNormalisedTime(currentMillis))
                    / 1000;
                int nanos = (int) (currentMillis % 1000) * 1000000;

                currentTime = new TimeData(seconds, nanos, timeZoneSeconds);
            }

            return currentTime;
        } else {
            if (localTime == null) {
                int seconds =
                    (int) (HsqlDateTime.getNormalisedTime(
                        currentMillis + +timeZoneSeconds * 1000)) / 1000;
                int nanos = (int) (currentMillis % 1000) * 1000000;

                localTime = new TimeData(seconds, nanos, 0);
            }

            return localTime;
        }
    }
981948
private Date timestampToDate(Timestamp ts) {
    long millis = ts.getTime();
    int nanos = ts.getNanos();
    return new Date(millis / 1000 * 1000 + nanos / 1000000);
  }
139741
private Tick getFullData(byte[] bin, int dec, Tick tick){
        long lastTradedtime = convertToLong(getBytes(bin, 44, 48)) * 1000;
        if(isValidDate(lastTradedtime)) {
            tick.setLastTradedTime(new Date(lastTradedtime));
        }else {
            tick.setLastTradedTime(null);
        }
        tick.setOi(convertToDouble(getBytes(bin, 48, 52)));
        tick.setOpenInterestDayHigh(convertToDouble(getBytes(bin, 52, 56)));
        tick.setOpenInterestDayLow(convertToDouble(getBytes(bin, 56, 60)));
        long tickTimeStamp = convertToLong(getBytes(bin, 60, 64)) * 1000;
        if(isValidDate(tickTimeStamp)) {
            tick.setTickTimestamp(new Date(tickTimeStamp));
        } else {
            tick.setTickTimestamp(null);
        }
        tick.setMarketDepth(getDepthData(bin, dec, 64, 184));
        return  tick;
    }
558431
static public Timestamp adjustTimestamp(Timestamp timestamp)
  {
    long milliToAdjust = ResultUtil.msDiffJulianToGregorian(timestamp);

    if (milliToAdjust != 0)
    {

      if (logger.isDebugEnabled())
      {
        logger.debug("adjust timestamp by {} days", milliToAdjust / 86400000);
      }

      Timestamp newTimestamp = new Timestamp(timestamp.getTime()
                                             + milliToAdjust);

      newTimestamp.setNanos(timestamp.getNanos());

      return newTimestamp;
    }
    else
    {
      return timestamp;
    }
  }
807697
def get_timestamp(dt=None):
    '''
    
    '''

    if dt is None: dt = datetime.datetime.utcnow()
    t = dt.utctimetuple()

    return calendar.timegm(t)
709356
function convertTimestampToBigEndian(timestamp) {
  // The timestamp parameter in Big-Endian UInt-64 format
  var buffer = new Buffer(8);
  buffer.fill(0);

  var high = ~~(timestamp / 0xffffffff); // jshint ignore:line
  var low = timestamp % (0xffffffff + 0x1); // jshint ignore:line

  buffer.writeUInt32BE(parseInt(high, 10), 0);
  buffer.writeUInt32BE(parseInt(low, 10), 4);

  return buffer;
}
185316
public static long convertToUtc(long millis, String tz)
    {
        long ret = millis;
        if(tz != null && tz.length() > 0)
        {
            DateTime dt = new DateTime(millis, DateTimeZone.forID(tz));
            ret = dt.withZoneRetainFields(DateTimeZone.forID("UTC")).getMillis();
        }
        return ret;
    }
789355
def timestamp_pb(self):
        
        inst = self if self.tzinfo is not None else self.replace(tzinfo=pytz.UTC)
        delta = inst - _UTC_EPOCH
        seconds = int(delta.total_seconds())
        nanos = self._nanosecond or self.microsecond * 1000
        return timestamp_pb2.Timestamp(seconds=seconds, nanos=nanos)
402181
public void writeBinary(final PacketOutputStream pos) throws IOException {
    Calendar calendar = Calendar.getInstance(timeZone);
    calendar.setTimeInMillis(ts.getTime());

    pos.write((byte) (fractionalSeconds ? 11 : 7));//length

    pos.writeShort((short) calendar.get(Calendar.YEAR));
    pos.write((byte) ((calendar.get(Calendar.MONTH) + 1) & 0xff));
    pos.write((byte) (calendar.get(Calendar.DAY_OF_MONTH) & 0xff));
    pos.write((byte) calendar.get(Calendar.HOUR_OF_DAY));
    pos.write((byte) calendar.get(Calendar.MINUTE));
    pos.write((byte) calendar.get(Calendar.SECOND));
    if (fractionalSeconds) {
      pos.writeInt(ts.getNanos() / 1000);
    }

  }
93525
def rfc1123_date(timestamp=None):
    """"""
    if timestamp is None:
        timestamp = time.time()
    timestamp = int(timestamp)
    global _cached_timestamp, _cached_datestring
    if timestamp != _cached_timestamp:
        # The time stamp must be GMT, and cannot be localized.
        tm = time.gmtime(timestamp)
        s = rfc1123_fmt.replace('%a', weekdays[tm.tm_wday]) \
                       .replace('%b', months[tm.tm_mon-1])
        _cached_datestring = time.strftime(s, tm)
        _cached_timestamp = timestamp
    return _cached_datestring