How to combine 2 java methods into one efficiently
<p>I'm trying to create a validate java class that receives 4 inputs from an object passed as 1 from the requester. The class needs to convert float inputs to string and evaluate each input to meet a certain format and then throw exceptions complete with error message and code when it fails. </p>

<p>What I have is in two methods and would like to know if there is a better way to combine these two classes into one validate method for the main class to call. I don't seem to be able to get around using the pattern/matcher concept to insure the inputs are formatted correctly. Any help you can give would be very much appreciated.</p>

<pre><code>public class Validator {
private static final String MoneyPattern ="^\\d{1,7}(\\.\\d{1,2})$" ;
private static final String PercentagePattern = "^\\d{1,3}\\.\\d{1,2}$";
private static final String CalendarYearPattern = "^20[1-9][0-9]$";


private int errorcode = 0;
private String errormessage = null;



public Validator(MyInput input){

}

private boolean verifyInput(){ 

    String Percentage = ((Float) input.getPercentage().toString();
    String Income = ((Float) input.getIncome().toString();
    String PublicPlan = ((Float) input.getPublicPlan().toString();
    String Year = ((Float) input.getYear();

try {
           if (!doesMatch(Income, MoneyPattern)) {

           errormessage = errormessage + "income,";
       }
       if (!doesMatch(PublicPlan, MoneyPattern)) {

           errormessage = errormessage + "insurance plan,";
       }
       if (!doesMatch(Percentage, PercentagePattern)) {

           errormessage = errormessage + "Percentage Plan,";
       }
       if (!doesMatch(Year, CalendarYearPattern)) {

           errormessage = errormessage + "Year,";
       }

     } catch (Exception e){
        errorcode = 111;
        errormessage =  e.getMessage();
     }

}

private boolean doesMatch(String s, String pattern) throws Exception{

    try {
    Pattern p = Pattern.compile(pattern);
    Matcher m = p.matcher(s);

    if (!s.equals("")){
    if(m.find()){
      return true;
    } else {
        return false;
    } 
    }else {
        return false;
    }
    } catch (PatternSyntaxException pse){
    errorcode = 111;
    errormessage = pse.getMessage();
    }
    }
}
</code></pre>
