@Test public void createDateStringFromIntegerInput_whenDateHasOneDigitMonthAndYear_addsZero() { assertEquals("0102", DateUtils.createDateStringFromIntegerInput(1, 2)); }
static String createDateStringFromIntegerInput( @IntRange(from = 1, to = 12) int month, @IntRange(from = 0, to = 9999) int year) { String monthString = String.valueOf(month); if (monthString.length() == 1) { monthString = "0" + monthString; } String yearString = String.valueOf(year); if (yearString.length() == 3) { return ""; } if (yearString.length() > 2) { yearString = yearString.substring(yearString.length() - 2); } else if (yearString.length() == 1) { yearString = "0" + yearString; } return monthString + yearString; }
DateUtils { static String createDateStringFromIntegerInput( @IntRange(from = 1, to = 12) int month, @IntRange(from = 0, to = 9999) int year) { String monthString = String.valueOf(month); if (monthString.length() == 1) { monthString = "0" + monthString; } String yearString = String.valueOf(year); if (yearString.length() == 3) { return ""; } if (yearString.length() > 2) { yearString = yearString.substring(yearString.length() - 2); } else if (yearString.length() == 1) { yearString = "0" + yearString; } return monthString + yearString; } }
DateUtils { static String createDateStringFromIntegerInput( @IntRange(from = 1, to = 12) int month, @IntRange(from = 0, to = 9999) int year) { String monthString = String.valueOf(month); if (monthString.length() == 1) { monthString = "0" + monthString; } String yearString = String.valueOf(year); if (yearString.length() == 3) { return ""; } if (yearString.length() > 2) { yearString = yearString.substring(yearString.length() - 2); } else if (yearString.length() == 1) { yearString = "0" + yearString; } return monthString + yearString; }  }
DateUtils { static String createDateStringFromIntegerInput( @IntRange(from = 1, to = 12) int month, @IntRange(from = 0, to = 9999) int year) { String monthString = String.valueOf(month); if (monthString.length() == 1) { monthString = "0" + monthString; } String yearString = String.valueOf(year); if (yearString.length() == 3) { return ""; } if (yearString.length() > 2) { yearString = yearString.substring(yearString.length() - 2); } else if (yearString.length() == 1) { yearString = "0" + yearString; } return monthString + yearString; }   }
DateUtils { static String createDateStringFromIntegerInput( @IntRange(from = 1, to = 12) int month, @IntRange(from = 0, to = 9999) int year) { String monthString = String.valueOf(month); if (monthString.length() == 1) { monthString = "0" + monthString; } String yearString = String.valueOf(year); if (yearString.length() == 3) { return ""; } if (yearString.length() > 2) { yearString = yearString.substring(yearString.length() - 2); } else if (yearString.length() == 1) { yearString = "0" + yearString; } return monthString + yearString; }    }