my service take a json body and saves it into db my json body looks like : { "id": "1059", "firstName": "max", "lastName": "sam", "emailAddress": "abc@gmail.com", "joiningDate": "2018-07-02T09:55:24.600", "endingDate": "2018-07-02T04:55:24.677" }
in my case date format is "yyyy-MM-dd'T'HH:mm:ss.SSS" and should not allow 'z' at the end of the date. but when i stored it into cassandra the field(timestamp) has the value "2018-07-02 09:55:24.600Z"
i am taking json date fields as string in the pojo and parsing as date then validating them and my validation looks like
public class DateValidator {
@Override
public boolean isValid(String field) {
if (field == null) {
return ignoreNull ? true : false;
}
boolean isValid = true;
try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS");
LocalDateTime.parse(field, formatter);
} catch (Exception exp) {
isValid = false;
}
return isValid;
}