A simple solution is to transfer the code to a handler class and call the methode from the IvyScript-Step.
If you still want the code in a ScriptStep, you could do the following:
import java.util.concurrent.atomic.AtomicReference;
AtomicReference date = new AtomicReference();
//date.set(new java.util.Date());
if ( date.get()!=null) {
ivy.log.info("bad");
} else {
ivy.log.info("good");
}