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());
} 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));