Scanning an int variable I have attemped to define a function which scan an int value in a specified range and returns that value. The lower bound is the lower of the two parameters, the upper bound is the larger of the two parameters.After invalid input, the function displays a message and repeats input (and message, if necessary ) until a valid value is entered, which is then returned. 

public static int scanYear() {


    do{
    int year = TextIO.getInt();
    if (checkDate (year) == true)
        return year;
    else
        TextIO.put("year not in the allowed range");

    }while (true);

} // end of scanYear


What is your opinion about the efficiency of the code , what can be improved ? Many thanks.
When it comes to user-input, efficiency really is not the point.... what does it matter if it takes 4 milliseconds to validate some data, or 4 nanoseconds? The user component of time dwarfs the rest.... Obvioulsy, if the code was taking more than 10 milliseconds I would be concerned, but I doubt that is the case.

With user-interface coding though, you have to think differently. In this case, you have to help the user. Specifically, telling a user that their input is wrong is more frustrating if you don't tell the user how to correct it....

Saying: " year not in the allowed range" is going to lead to lots of frustration.

Saying: "year must be between 1950 and 2013" is much better.

EDIT: In fact, when prompting the user to enter the data, it should inform the user what values will be valid before getting the value:

Please enter a year between 1950 and 2013 (inclusive):
...
Sorry, the value 2014 is not between 1950 and 2013, please enter a valid year: