/**
     * 检验输入是否为正确的日期格式(不含秒的任何情况),严格要求日期正确性,格式:yyyy-MM-dd HH:mm
     * @param sourceDate
     * @return
     */
    public static boolean checkDate(String sourceDate){
        if(sourceDate==null){
            return false;
        }
        try {
               SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
               dateFormat.setLenient(false);
               dateFormat.parse(sourceDate);
               return true;
        } catch (Exception e) {
        }
         return false;
    }
   
    /**
     * 根据日期获得日期(不含秒的任何情况),严格要求日期正确性,格式:yyyy-MM-dd HH:mm
     * @param sourceDate
     * @return
     */
    public static Date getDate(String sourceDate) throws DataFormatException{
           if(sourceDate==null){
               throw new DataFormatException("源数据为null");
           }
           try {
                     SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                     dateFormat.setLenient(false);
                      return dateFormat.parse(sourceDate);
           } catch (Exception e) {
                     throw new DataFormatException("源数据格式错误");
           }
    }


//日期格式可以自定义.
    public static void main(String[] args) throws IOException {
             String s="2006-01-30 12:26";
             System.out.println(s+"是否为日期:"+Test.checkDate(s));

             s="2006-1-30 12:26";
             System.out.println(s+"是否为日期:"+Test.checkDate(s));
        
            s="2006-01-32 12:26";
            System.out.println(s+"是否为日期:"+Test.checkDate(s));
    }