public static Timestamp convertTimestamp(Value value,Calendar calendar){
  if (value == ValueNull.INSTANCE) {
    return null;
  }
  ValueTimestamp ts=(ValueTimestamp)value.convertTo(Value.TIMESTAMP);
  Calendar cal=(Calendar)calendar.clone();
  cal.clear();
  cal.setLenient(true);
  long dateValue=ts.getDateValue();
  long nanos=ts.getTimeNanos();
  long millis=nanos / 1000000;
  nanos-=millis * 1000000;
  long s=millis / 1000;
  millis-=s * 1000;
  long m=s / 60;
  s-=m * 60;
  long h=m / 60;
  m-=h * 60;
  setCalendarFields(cal,yearFromDateValue(dateValue),monthFromDateValue(dateValue),dayFromDateValue(dateValue),(int)h,(int)m,(int)s,(int)millis);
  long ms=cal.getTimeInMillis();
  Timestamp x=new Timestamp(ms);
  x.setNanos((int)(nanos + millis * 1000000));
  return x;
}

public static Timestamp convertTimestamp ( Value value , Calendar calendar ) { if ( value == ValueNull . INSTANCE ) { return null ; } ValueTimestamp ts = ( ValueTimestamp ) value . convertTo ( Value . TIMESTAMP ) ; Calendar cal = ( Calendar ) calendar . clone ( ) ; cal . clear ( ) ; cal . setLenient ( true ) ; long dateValue = ts . getDateValue ( ) ; long nanos = ts . getTimeNanos ( ) ; long millis = nanos / 1000000 ; nanos -= millis * 1000000 ; long s = millis / 1000 ; millis -= s * 1000 ; long m = s / 60 ; s -= m * 60 ; long h = m / 60 ; m -= h * 60 ; setCalendarFields ( cal , yearFromDateValue ( dateValue ) , monthFromDateValue ( dateValue ) , dayFromDateValue ( dateValue ) , ( int ) h , ( int ) m , ( int ) s , ( int ) millis ) ; long ms = cal . getTimeInMillis ( ) ; Timestamp x = new Timestamp ( ms ) ; x . setNanos ( ( int ) ( nanos + millis * 1000000 ) ) ; return x ; }
convert the timestamp to the specified time zone .
