/** * Convert a time value to a time, using the default * timezone. * * @param nanos the nanoseconds since midnight * @return the time */ public static Time convertNanoToTime(long nanos) { long millis = nanos / 1000000; long s = millis / 1000; millis -= s * 1000; long m = s / 60; s -= m * 60; long h = m / 60; m -= h * 60; long ms = getMillis(null, 1970, 1, 1, (int) (h % 24), (int) m, (int) s, (int) millis); return new Time(ms); }
/** * Convert a date value to a date, using the default timezone. * * @param dateValue the date value * @return the date */ public static Date convertDateValueToDate(long dateValue) { long millis = getMillis(null, yearFromDateValue(dateValue), monthFromDateValue(dateValue), dayFromDateValue(dateValue), 0, 0, 0, 0); return new Date(millis); }
/** * Convert a date value / time value to a timestamp, using the default * timezone. * * @param dateValue the date value * @param timeNanos the nanoseconds since midnight * @return the timestamp */ public static Timestamp convertDateValueToTimestamp(long dateValue, long timeNanos) { long millis = timeNanos / 1000000; timeNanos -= millis * 1000000; long s = millis / 1000; millis -= s * 1000; long m = s / 60; s -= m * 60; long h = m / 60; m -= h * 60; long ms = getMillis(null, yearFromDateValue(dateValue), monthFromDateValue(dateValue), dayFromDateValue(dateValue), (int) h, (int) m, (int) s, 0); Timestamp ts = new Timestamp(ms); ts.setNanos((int) (timeNanos + millis * 1000000)); return ts; }
int hour = minute / 60; minute -= hour * 60; long millis = DateTimeUtils.getMillis( tz, year, month, day, hour, minute, (int) second, (int) ms); ms = DateTimeUtils.convertToLocal(