import java.text.SimpleDateFormat SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd000000") String ldapDate = sf.format(new Date()) + "Z" out.println(ldapDate)