Adjust timestamp for dates before 1582-10-05

@param timestamp needs to be adjusted
@return adjusted timestamp
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;
    }
  }
1304854
public static String longToDateTime(long timestamp) {
        Date date = new Date(timestamp * 1000);
        DateFormat formatter = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
        return formatter.format(date);
    }
981948
private Date timestampToDate(Timestamp ts) {
    long millis = ts.getTime();
    int nanos = ts.getNanos();
    return new Date(millis / 1000 * 1000 + nanos / 1000000);
  }
11321
private function timestampHasExpired($timestamp) {
        $year   = substr($timestamp, 0, 4);
        $month  = substr($timestamp, 5, 2);
        $day    = substr($timestamp, 8, 2);
        $hour   = substr($timestamp, 11, 2);
        $minute = substr($timestamp, 14, 2);
        $second = substr($timestamp, 17, 2);

        $timestamp = gmmktime($hour, $minute, $second, $month, $day, $year);

        $diff = time() - $timestamp;

        if ($diff > $this->maxDiff || $diff < -$this->maxDiff) {
            return true;
        }

        return false;
    }
683394
public static function ToTimezone($Timestamp) {
      static $GuestHourOffset;
      $Now = time();
      
      // Alter the timestamp based on the user's hour offset
      $Session = Gdn::Session();
      $HourOffset = 0;
      
      if ($Session->UserID > 0) {
         $HourOffset = $Session->User->HourOffset;
      } elseif (class_exists('DateTimeZone')) {
         if (!isset($GuestHourOffset)) {
            $GuestTimeZone = C('Garden.GuestTimeZone');
            if ($GuestTimeZone) {
               try {
                  $TimeZone = new DateTimeZone($GuestTimeZone);
                  $Offset = $TimeZone->getOffset(new DateTime('now', new DateTimeZone('UTC')));
                  $GuestHourOffset = floor($Offset / 3600);
               } catch (Exception $Ex) {
                  $GuestHourOffset = 0;
                  LogException($Ex);
               }
            }
         }
         $HourOffset = $GuestHourOffset;
      }
      
      if ($HourOffset <> 0) {
         $SecondsOffset = $HourOffset * 3600;
         $Timestamp += $SecondsOffset;
         $Now += $SecondsOffset;
      }
      
      return $Timestamp;
   }
1287899
private long updateBaseTime(final long timestamp) {
    // We force the starting timestamp to be on a MAX_TIMESPAN boundary
    // so that all TSDs create rows with the same base time. Otherwise
    // we'd need to coordinate TSDs to avoid creating rows that cover
    // overlapping time periods.
    final long base_time = timestamp - (timestamp % Const.MAX_TIMESPAN);
    // Clone the row key since we're going to change it. We must clone it
    // because the HBase client may still hold a reference to it in its
    // internal datastructures.
    row = Arrays.copyOf(row, row.length);
    Bytes.setInt(row, (int) base_time, Const.SALT_WIDTH() + tsdb.metrics.width());
    RowKey.prefixKeyWithSalt(row); // in case the timestamp will be involved in
                                   // salting later
    tsdb.scheduleForCompaction(row, (int) base_time);
    return base_time;
  }
795605
public static Timestamp of(java.sql.Timestamp timestamp) {
    return ofTimeSecondsAndNanos(timestamp.getTime() / 1000, timestamp.getNanos());
  }
1029736
public void setTimestamp(Timestamp timestamp) {
        if (timestamp == null) {
            _properties.remove(AMQP_PROP_TIMESTAMP);
            return;
        }
        
        _properties.put(AMQP_PROP_TIMESTAMP, timestamp);
    }
350697
public static String changeTimestampToNewFormat(String originDateFormat,
            String originTimestamp, String newDateFormat) {
        return getTime(
                changeTimestampToLong(getSimpleDateFormat(originDateFormat),
                        originTimestamp), newDateFormat);
    }
670331
public static long changeTimestampToLong(String dateFormat,
            String timestamp, String zoneId) {
        return changeTimestampToLong(getSimpleDateFormat(dateFormat, zoneId),
                timestamp);
    }
979129
public static DateTime parseTimeToday(String timeString) {
		timeString = StrUtil.format("{} {}", today(), timeString);
		return parse(timeString, DatePattern.NORM_DATETIME_FORMAT);
	}
117545
public static Timestamp toTimestamp(DateTime dt) {
        if (dt == null) {
            return null;
        } else {
            return new Timestamp(dt.getMillis());
        }
    }
837675
public static function longDate($timestamp = null)
    {
        $l = self::getLocale();
        return self::date($l->shortDateTime, $timestamp);
    }
1358325
public static String changeFormatAndTimeZoneToOffsetDateTime(
            String dateFormat, String dateString) {
        return getOffsetDateTime(changeTimestampToLong(dateFormat, dateString))
                .toString();
    }
1040137
public static function roundTimestampToYear($timestamp)
    {
        $year  = date('Y', $timestamp);
        
        $roundedTimestamp = mktime(0, 0, 0, $month=1, $day=1, $year);
        
        return $roundedTimestamp;
    }
399399
public static function roundTimestampDownToMonth($timestamp)
    {
        $month = date('n', $timestamp);
        $year  = date('Y', $timestamp);
                
        $roundedTimestamp = mktime(0, 0, 0, $month, $day="01", $year);
                
        return $roundedTimestamp;
    }
711351
public static String timeStampToString(final Timestamp timestamp, final String format) {
        return dateToString(new Date(timestamp.getTime()), format);
    }