首页 > 代码库 > Date---String is 合法的date 方法---

Date---String is 合法的date 方法---

package com.etc.jichu;

import java.text.SimpleDateFormat;

public class IsDate {
public static boolean isValidDate(String str)
{
	boolean convertSuccess=true;
	SimpleDateFormat format=new SimpleDateFormat("YYYY/MM/dd HH:mm");
	try {
		format.setLenient(false);//不宽松地验证日期
		format.parse(str);
	} catch (Exception e) {
		convertSuccess=false;//若 抛java.text.ParseException或者NullPointerException,就说明格式不对
	}
	return convertSuccess;
}
}

  

Date---String is 合法的date 方法---