⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testvalidator.java

📁 这是一个关于J2EE的开源包common里的许多组件的示例应用程序,可以借鉴.
💻 JAVA
字号:
/**
 * Title : Base Dict Class
 * Description : here Description is the function of class, here maybe multirows    
 * @author        kevin
 * @Version       1.0 
 */

package validator;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

import org.apache.commons.validator.Field;
import org.apache.commons.validator.GenericValidator;
import org.apache.commons.validator.ValidatorUtil;

/**
 * Class description goes here.
 * @version 1.0  2005-11-9 
 * @author kevin
 */
public class TestValidator
{ /**
	    * Checks if the field is required.
    *
    * @param 	value 		The value validation is being performed on.
    * @return	boolean		If the field isn't null and 
    *                           has a length greater than zero, 
    *                           true is returned.  
    *                           Otherwise false.
   */
   public static boolean validateRequired(Object bean, Field field) {
      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
      return !GenericValidator.isBlankOrNull(value);
   }
   
   
   public static boolean validateInt(Object bean, Field field) {
    String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
    return GenericValidator.isInt(value);
 }
   
   public static void main(String[] s) 
   {
   	SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
    formatter.setLenient(false);
    try {
        formatter.parse("12/31/2");
    } catch(ParseException e) {
        e.printStackTrace() ;
    }
   }
}  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -