对时间格式进行判断

改变SimpleDateFormat format = new SimpleDateFormat(“yyyyMMdd”);中的格式即可

public static boolean isValidDate(String str) {
		     boolean convertSuccess=true;
		     SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
		     try {
		          format.setLenient(false);
		          format.parse(str);
		       } catch (ParseException e) {
		          convertSuccess=false;
		       } 
		       return convertSuccess;
		}

猜你喜欢

转载自blog.csdn.net/Abracadabra__/article/details/85264762