Extracts the date part from a timestamp.

@param millis The timestamp from which to extract the date.
@param tz The time zone of the date.
@return The extracted date.
542278
public Date convertToDate(long millis, TimeZone tz) {

    // no adjustments for the inifity hack values
    if (millis <= PGStatement.DATE_NEGATIVE_INFINITY
        || millis >= PGStatement.DATE_POSITIVE_INFINITY) {
      return new Date(millis);
    }
    if (tz == null) {
      tz = getDefaultTz();
    }
    if (isSimpleTimeZone(tz.getID())) {
      // Truncate to 00:00 of the day.
      // Suppose the input date is 7 Jan 15:40 GMT+02:00 (that is 13:40 UTC)
      // We want it to become 7 Jan 00:00 GMT+02:00
      // 1) Make sure millis becomes 15:40 in UTC, so add offset
      int offset = tz.getRawOffset();
      millis += offset;
      // 2) Truncate hours, minutes, etc. Day is always 86400 seconds, no matter what leap seconds
      // are
      millis = millis / ONEDAY * ONEDAY;
      // 2) Now millis is 7 Jan 00:00 UTC, however we need that in GMT+02:00, so subtract some
      // offset
      millis -= offset;
      // Now we have brand-new 7 Jan 00:00 GMT+02:00
      return new Date(millis);
    }
    Calendar cal = calendarWithUserTz;
    cal.setTimeZone(tz);
    cal.setTimeInMillis(millis);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return new Date(cal.getTimeInMillis());
  }
622205
public static Expression millisToZone(Expression expression, String timeZoneName, String format) {
        if (format == null || format.isEmpty()) {
            return x("MILLIS_TO_ZONE(" + expression.toString() + ", \"" + timeZoneName + "\")");
        }
        return x("MILLIS_TO_ZONE(" + expression.toString() + ", \"" + timeZoneName + "\"" +
                ", \"" + format + "\")");
    }
278118
public static String dateFormat(long ts, String format, TimeZone tz) {
		SimpleDateFormat formatter = FORMATTER_CACHE.get(format);
		formatter.setTimeZone(tz);
		Date dateTime = new Date(ts);
		return formatter.format(dateTime);
	}
436985
public static ZonedDateTime getZonedDataTime(long timestamp,
            String zoneId) {
        return Instant.ofEpochMilli(timestamp).atZone(getZoneId(zoneId));
    }
1368281
public String toISO8601Date(long utcEpochMillis, @Nullable DateTimeZone dtz) {
		return toISO8601Date(new DateTime(utcEpochMillis, dtz), dtz);
	}
1015696
public static Timestamp parseTimestamp(String timestamp) {
    TemporalAccessor temporalAccessor = timestampParser.parse(timestamp);
    Instant instant = Instant.from(temporalAccessor);
    return ofTimeSecondsAndNanos(instant.getEpochSecond(), instant.getNano());
  }
981948
private Date timestampToDate(Timestamp ts) {
    long millis = ts.getTime();
    int nanos = ts.getNanos();
    return new Date(millis / 1000 * 1000 + nanos / 1000000);
  }
443167
public static String dateSub(long ts, int days, TimeZone tz) {
		ZoneId zoneId = tz.toZoneId();
		Instant instant = Instant.ofEpochMilli(ts);
		ZonedDateTime zdt = ZonedDateTime.ofInstant(instant, zoneId);
		long resultTs = zdt.minusDays(days).toInstant().toEpochMilli();
		return dateFormat(resultTs, DATE_FORMAT_STRING, tz);
	}
1334399
public String timeToString(java.util.Date time, boolean withTimeZone) {
    Calendar cal = null;
    if (withTimeZone) {
      cal = calendarWithUserTz;
      cal.setTimeZone(timeZoneProvider.get());
    }
    if (time instanceof Timestamp) {
      return toString(cal, (Timestamp) time, withTimeZone);
    }
    if (time instanceof Time) {
      return toString(cal, (Time) time, withTimeZone);
    }
    return toString(cal, (Date) time, withTimeZone);
  }
1156955
public static long timestampFloor(TimeUnitRange range, long ts, TimeZone tz) {
		// assume that we are at UTC timezone, just for algorithm performance
		long offset = tz.getOffset(ts);
		long utcTs = ts + offset;

		switch (range) {
			case HOUR:
				return floor(utcTs, MILLIS_PER_HOUR) - offset;
			case DAY:
				return floor(utcTs, MILLIS_PER_DAY) - offset;
			case MONTH:
			case YEAR:
			case QUARTER:
				int days = (int) (utcTs / MILLIS_PER_DAY + EPOCH_JULIAN);
				return julianDateFloor(range, days, true) * MILLIS_PER_DAY - offset;
			default:
				// for MINUTE and SECONDS etc...,
				// it is more effective to use arithmetic Method
				throw new AssertionError(range);
		}
	}
925529
public static Calendar getCalendar(TimeZone tz, Locale locale)
    {
        if(tz == null)
            tz = getCurrentTimeZone();
        if(locale == null)
            locale = getCurrentLocale();
        return Calendar.getInstance(tz, locale);
    }
445343
private String formatExemplarLocation(TimeZone tz) {
        String location = getTimeZoneNames().getExemplarLocationName(ZoneMeta.getCanonicalCLDRID(tz));
        if (location == null) {
            // Use "unknown" location
            location = getTimeZoneNames().getExemplarLocationName(UNKNOWN_ZONE_ID);
            if (location == null) {
                // last resort
                location = UNKNOWN_LOCATION;
            }
        }
        return location;
    }
1369444
public static String datetime(long millis) {
		if (sFormat == null) {
			sFormat = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss", TimeZone.getTimeZone("UTC"),
					US);
		}
		return sFormat.format(millis);
	}
584689
public static Long toTimestamp(String dateStr, String format, TimeZone tz) {
		SimpleDateFormat formatter = FORMATTER_CACHE.get(format);
		formatter.setTimeZone(tz);
		try {
			return formatter.parse(dateStr).getTime();
		} catch (ParseException e) {
			return null;
		}
	}
766792
public static Calendar calendar(long millis) {
		final Calendar cal = Calendar.getInstance();
		cal.setTimeInMillis(millis);
		return cal;
	}
1066669
def _get_tz(tz):
    
    zone = timezones.get_timezone(tz)
    if zone is None:
        zone = tz.utcoffset().total_seconds()
    return zone
34689
public static String timeToString(long timeMillis) {
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        return dateFormat.format(new Date(timeMillis));
    }