【发布时间】:2016-01-08 23:59:34
【问题描述】:
我有一个字符串格式的日期YYYY/MM/DD HH:MM:SS,我需要使用前置条件 google guava 类对其进行验证。我在很多其他地方使用checkArgument 方法。我如何使用checkArgument 方法来验证startDate 以确保它仅采用这种格式YYYY/MM/DD HH:MM:SS,如果不是,则抛出IllegalArgumentException 和一些消息。
public Builder startDate(String startDate) {
// validate startDate here using checkArgument if it is not valid then throw IllegalArgumentException.
this.sDate = startDate;
return this;
}
这里如何使用 checkArgument 方法?
【问题讨论】:
标签: java date preconditions