进行日期验证的最佳方法是什么,包括检查月份是否在 1 到 12 之间以及天数是否在 1 到最大值之间。相应月份的天数(包括闰年)?
最佳答案
以压缩且更干净的方式:
Calendar cal = Calendar.getInstance();
try {
cal.setTime(theConcernedDate);
}
catch (Exception e) {
System.out.println("Invalid date");
}
关于java - 日期验证,包括相应月份的天数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12625469/