@Test public void testIsValidYear() { String s = ""; assertFalse(Utils.isValidYear(s)); s = "what"; assertFalse(Utils.isValidYear(s)); s = "" + (Constants.MIN_YEAR - 1); assertFalse(Utils.isValidYear(s)); s = "" + (Constants.MAX_YEAR + 1); assertFalse(Utils.isValidYear(s)); s = "" + (Constants.MIN_YEAR + Constants.MAX_YEAR)/2; assertTrue(Utils.isValidYear(s)); }
public static boolean isValidYear(String s) { int year = 0; try { year = Integer.parseInt(s); } catch (NumberFormatException e) { return false; } return year >= Constants.MIN_YEAR && year <= Constants.MAX_YEAR; }
Utils { public static boolean isValidYear(String s) { int year = 0; try { year = Integer.parseInt(s); } catch (NumberFormatException e) { return false; } return year >= Constants.MIN_YEAR && year <= Constants.MAX_YEAR; } }
Utils { public static boolean isValidYear(String s) { int year = 0; try { year = Integer.parseInt(s); } catch (NumberFormatException e) { return false; } return year >= Constants.MIN_YEAR && year <= Constants.MAX_YEAR; }  }
Utils { public static boolean isValidYear(String s) { int year = 0; try { year = Integer.parseInt(s); } catch (NumberFormatException e) { return false; } return year >= Constants.MIN_YEAR && year <= Constants.MAX_YEAR; }  static String tokenToAuthString(String token); static void showToast(Context context, String errorMessage); static SharedPreferences.Editor getSharedPrefEditor(Context context); static SharedPreferences getSharedPref(Context context); static void logout(Context context); static Uri getNewImageUri(Context context); static boolean isLocalUrl(String url); static boolean isClose(double a, double b); static boolean objectEquals(Object a, Object b); static double roundToDecimals(double num, int precision); static boolean isValidYear(String s); static String yearString(int year); }
Utils { public static boolean isValidYear(String s) { int year = 0; try { year = Integer.parseInt(s); } catch (NumberFormatException e) { return false; } return year >= Constants.MIN_YEAR && year <= Constants.MAX_YEAR; }  static String tokenToAuthString(String token); static void showToast(Context context, String errorMessage); static SharedPreferences.Editor getSharedPrefEditor(Context context); static SharedPreferences getSharedPref(Context context); static void logout(Context context); static Uri getNewImageUri(Context context); static boolean isLocalUrl(String url); static boolean isClose(double a, double b); static boolean objectEquals(Object a, Object b); static double roundToDecimals(double num, int precision); static boolean isValidYear(String s); static String yearString(int year);  }