Modeling Time in Java Programs for Automatic Error Detection