← all problems

reformatDate 🌶️🌶️🌶️

A date is written as month/day/year, with slashes and no leading zeros, like "3/14/2024" or "12/5/1999". Write a method that takes one String parameter, date, and returns it written as year-month-day with hyphens, keeping the month and day exactly as they were written. For example, reformatDate("3/14/2024") should return "2024-3-14".

Preconditions: date has exactly two slashes and a four-digit year.