I have a date in string format YYYY/MM/DD HH:MM:SS
which I need to validate using preconditions google guava class. I am using checkArgument
method in lot of other places. How can I use checkArgument
method to validate startDate
to make sure it is in this format only YYYY/MM/DD HH:MM:SS
and if they are not, then throw IllegalArgumentException with some message.
public Builder startDate(String startDate) {
// validate startDate here using checkArgument if it is not valid then throw IllegalArgumentException.
this.sDate = startDate;
return this;
}
How can I use checkArgument method here?