better error handling, support java.util.Date