public static <T extends BaseEntity> T create(Class<T> baseEntityClass) { T obj = null; try { obj = baseEntityClass.newInstance(); } catch (Exception e) { logger.log(Level.SEVERE, "Instantiating " + baseEntityClass.getName(), e); return (null); } obj.setId(rand.nextInt(5000)); Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); obj.setCreatedDate(cal); obj.setModifiedDate(cal); return (obj); }