@SqlType(StandardTypes.DATE)
public static long castToDate(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP) long value)
{
// round down the current timestamp to days
ISOChronology chronology = getChronology(session.getTimeZoneKey());
long date = chronology.dayOfYear().roundFloor(value);
// date is currently midnight in timezone of the session
// convert to UTC
return date + chronology.getZone().getOffset(date);
}