import java.text.ParseException;
import java.text.SimpleDateFormat;
/**
*
* 说明:判断是否为日期格式
* @param str
* @return
*/
public static boolean isValidDate(String str) {
// 指定日期格式为四位年/两位月份/两位日期,注意yyyy/MM/dd区分大小写;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
// 设置lenient为false. 否则SimpleDateFormat会比较宽松地验证日期,比如2007/02/29会被接受,并转换成2007/03/01
format.setLenient(false);
format.parse(str);
return true;
} catch (ParseException e) {
// 如果throw java.text.ParseException或者NullPointerException,就说明格式不对
return false;
}
}
/**
*
* 说明:判断是否为BigDecimal
* @param str
* @return
*/
public static boolean isBigDecimal(String integer) {
try{
BigDecimal bd = new BigDecimal(integer);
//bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
return true;
}catch(NumberFormatException e)
{
return false;
}
}