@Test public void normalizeDifferentCenturyShouldFail() { Calendar now = Calendar.getInstance(); int year = 1997; now.set(Calendar.YEAR, year); assertNotEquals(ModelUtils.normalizeYear(97, now), 2097); }
static int normalizeYear(int year, Calendar now) { if (year < 100 && year >= 0) { String currentYear = String.valueOf(now.get(Calendar.YEAR)); String prefix = currentYear.substring(0, currentYear.length() - 2); year = Integer.parseInt(String.format(Locale.US, "%s%02d", prefix, year)); } return year; }
ModelUtils { static int normalizeYear(int year, Calendar now) { if (year < 100 && year >= 0) { String currentYear = String.valueOf(now.get(Calendar.YEAR)); String prefix = currentYear.substring(0, currentYear.length() - 2); year = Integer.parseInt(String.format(Locale.US, "%s%02d", prefix, year)); } return year; } }
ModelUtils { static int normalizeYear(int year, Calendar now) { if (year < 100 && year >= 0) { String currentYear = String.valueOf(now.get(Calendar.YEAR)); String prefix = currentYear.substring(0, currentYear.length() - 2); year = Integer.parseInt(String.format(Locale.US, "%s%02d", prefix, year)); } return year; }  }
ModelUtils { static int normalizeYear(int year, Calendar now) { if (year < 100 && year >= 0) { String currentYear = String.valueOf(now.get(Calendar.YEAR)); String prefix = currentYear.substring(0, currentYear.length() - 2); year = Integer.parseInt(String.format(Locale.US, "%s%02d", prefix, year)); } return year; }   }
ModelUtils { static int normalizeYear(int year, Calendar now) { if (year < 100 && year >= 0) { String currentYear = String.valueOf(now.get(Calendar.YEAR)); String prefix = currentYear.substring(0, currentYear.length() - 2); year = Integer.parseInt(String.format(Locale.US, "%s%02d", prefix, year)); } return year; }    }