datetime dt = new datetime(d); return dt.toTimeBytes();
if (cal == null) { return d; } else { long time = d.getTime() + (invertTimeZone ? -1 : 1) * (cal.getTimeZone().getRawOffset() - Calendar.getInstance().getTimeZone().getRawOffset());  return new Time(time); }
    public byte[] encodeTime(Time d) {        datetime dt = new datetime(d);        return dt.toTimeBytes();    }