if(resellerContract.getStartDate() == null ||
DateUtil.getDateInformat(DateUtil.YYY_MM_DD, resellerContract.getStartDate()).before(DateUtil.getDateInformat(DateUtil.YYY_MM_DD,new Date()))){
validStartDate = false;
logger.error("SPAC Start date is null");
validationErrors.add(new ValidationError(ResellerServiceErrorCode.SPAC_START_DATE_NULL));
}
i want to seperate validation for both differnt condtion how i can do that using if else or if if or what should i use because i want to send different error message
Can't you just use a "elseif" statement?
like eg:
if(resellerContract.getStartDate() == null) {
....
validStartDate = false;
logger.error("SPAC Start date is null");
validationErrors.add(new ValidationError(ResellerServiceErrorCode.SPAC_START_DATE_NULL));
} else if (DateUtil.getDateInformat(DateUtil.YYY_MM_DD, resellerContract.getStartDate()).before(DateUtil.getDateInformat(DateUtil.YYY_MM_DD,new Date()))){
....
validStartDate = false;
logger.error("SPAC Start date is null");
validationErrors.add(new ValidationError(ResellerServiceErrorCode.SPAC_START_DATE_NULL));
}
Why not just separate the compound if statement into two if statements? Please clarify your intention; I feel that I may be giving you a trivial answer.
if (resellerContract.getStartDate() == null) {
validStartDate = false;
logger.error("SPAC Start date is null");
validationErrors.add(new ValidationError(ResellerServiceErrorCode.SPAC_START_DATE_NULL));
}
if (DateUtil.getDateInformat(DateUtil.YYY_MM_DD, resellerContract.getStartDate())
.before(DateUtil.getDateInformat(DateUtil.YYY_MM_DD,new Date()))) {
//some other code
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.