1:) 字符串转换成时间
1 2 3 4 5 6 7 8 9 10 11 12 13 |
SimpleDateFormat formatter = new SimpleDateFormat ('yyyy.MM.dd'); //假定像2002.07.04的是合法日期其他都非法。 String str='2002.07.04'; ParsePosition pos = new ParsePosition(0); Date dt=formatter.parse(str,pos); if(dt!=null) { //是合法日期 } else { //非法日期 } |
2:)两个日期相减 […]