Here you can find the source of isYear(String str, boolean nullCheck)
public static boolean isYear(String str, boolean nullCheck)
//package com.java2s; //License from project: Apache License public class Main { public static boolean isYear(String str, boolean nullCheck) { if (nullCheck == false || isRequired(str)) { if (str == null) { return true; }/*w ww .jav a2s . co m*/ if (isNumber(str, false)) { int year = Integer.parseInt(str.trim()); if (year < 1500 && year > 2999) { return false; } } } else { return false; } return true; } public static boolean isRequired(String str) { if (str == null || str.trim().length() == 0) { return false; } return true; } public static boolean isNumber(String str, boolean nullCheck) { if (nullCheck == false || isRequired(str)) { if (str == null) { return true; } try { Integer.parseInt(str.trim()); } catch (NumberFormatException nfe) { return false; } } else { return false; } return true; } }