FastPrepCompare Calendar Dates

Compare Calendar Dates

Wells Fargo logoWells Fargo● EasyINTERNPHONE SCREEN
Learn

Problem statement

Given two valid Gregorian calendar dates firstDate and secondDate in dd/mm/yyyy format, return the later date in the same format.

If the dates are equal, return firstDate.

Function

laterDate(firstDate: String, secondDate: String) → String

Examples

Example 1

firstDate = "15/04/2026"secondDate = "20/03/2027"return = "20/03/2027"

The year 2027 is later than 2026.

Example 2

firstDate = "29/02/2024"secondDate = "01/03/2024"return = "01/03/2024"

March 1 follows February 29 in the leap year 2024.

Example 3

firstDate = "07/09/2030"secondDate = "07/09/2030"return = "07/09/2030"

The dates are equal, so the function returns firstDate.

Constraints

  • Each input contains exactly 10 characters in dd/mm/yyyy format.
  • Both inputs are valid Gregorian dates with years from 1900 through 9999.
  • Day and month values are zero-padded to two digits, and the year is zero-padded to four digits.

More Wells Fargo problems

See Wells Fargo hiring insights
public String laterDate(String firstDate, String secondDate) {
  // write your code here
}
firstDate"15/04/2026"
secondDate"20/03/2027"
expected"20/03/2027"
Checking account…