use of net.sf.saxon.value.TimeValue in project teiid by teiid.
the class XQueryEvaluator method convertToAtomicValue.
public static AtomicValue convertToAtomicValue(Object value) throws TransformerException {
if (value instanceof java.util.Date) {
// special handling for time types
java.util.Date d = (java.util.Date) value;
DateTimeValue tdv = DateTimeValue.fromJavaDate(d);
if (value instanceof Date) {
value = new DateValue(tdv.getYear(), tdv.getMonth(), tdv.getDay(), tdv.getTimezoneInMinutes(), true);
} else if (value instanceof Time) {
value = new TimeValue(tdv.getHour(), tdv.getMinute(), tdv.getSecond(), tdv.getMicrosecond(), tdv.getTimezoneInMinutes());
} else if (value instanceof Timestamp) {
Timestamp ts = (Timestamp) value;
value = tdv.add(DayTimeDurationValue.fromMicroseconds(ts.getNanos() / 1000));
}
return (AtomicValue) value;
}
JPConverter converter = JPConverter.allocate(value.getClass(), null, null);
return (AtomicValue) converter.convert(value, null);
}
Aggregations