what the heck do u want? first of all, what is GuiTextField. Second of all, to check what? to check the validation or to parse to java.util.Date instance? To check the validation, using java.text.SimpleDateFormat to parse. You have the pattern "dd/MM/yyyy HH:mm:ss"; and if exception occurs, the input is invalid. To parse to Date instance, using the same approach.

解决方案 »

  1.   

    public static java.util.Date str2date(String s, String pattern){
            
            SimpleDateFormat df = (SimpleDateFormat)DateFormat.getDateInstance();        
            synchronized(df) {
            
                df.applyPattern(pattern);        
                df.setLenient(false);            try {
            
                    java.util.Date date = df.parse(s);                return date;            } catch(Exception e) {
                }
            }
            
            return null;
        }
    pattern = "dd/MM/yyyy HH:mm:ss"
    用这个方法不返回null就是正确的。
      

  2.   

    Thanks
     If user input String value [10/10/20 13:12:12]  after check,
    it is right,  but date value is [10/10/0020 13:12:12], this value is not accept by user,I want to except it in this check method,
     Date is java.util.Date, check if invalid.
    Thanks
      

  3.   

    dd/MM/yy HH:mm:ss
    suggest u to read java.text.SimpleDateFormat carefully be4 asking. Also, check ur grammar mistakes.