Beispiel #1
0
 /**
  * @param years [1960-20xx]
  * @param months [1-12]
  * @param days [1-31]
  * @param hours [0-23]
  * @param minutes [0-59]
  * @param seconds [0-59]
  * @param millis [0-99]
  * @param micros [0-99]
  * @param nanos [0-99]
  * @return Timestamp
  */
 public static TimestampValue from(
     final int years,
     final int months,
     final int days,
     final int hours,
     final int minutes,
     final int seconds,
     final int millis,
     final int micros,
     final int nanos) {
   final GregorianCalendar cal =
       new GregorianCalendar(years, months - 1, days, hours, minutes, seconds);
   final long offset = cal.getTimeZone().getOffset(cal.getTimeInMillis());
   final Timestamp timestamp = new Timestamp(cal.getTimeInMillis() + offset);
   timestamp.setNanos(
       (millis * TimestampValue.MILLIS_TO_NANOS)
           + (micros * TimestampValue.MICROS_TO_NANOS)
           + nanos);
   return TimestampValue.from(timestamp);
 }
Beispiel #2
0
 /**
  * @param value Value
  * @return Timestamp
  */
 public static TimestampValue from(final Date value) {
   return TimestampValue.from(new Timestamp(value.getTime()));
 }