Class Solution

java.lang.Object
g1501_1600.s1507_reformat_date.Solution

public class Solution extends Object
1507 - Reformat Date.<p>Easy</p> <p>Given a <code>date</code> string in the form <code>Day Month Year</code>, where:</p> <ul> <li><code>Day</code> is in the set <code>{&quot;1st&quot;, &quot;2nd&quot;, &quot;3rd&quot;, &quot;4th&quot;, ..., &quot;30th&quot;, &quot;31st&quot;}</code>.</li> <li><code>Month</code> is in the set <code>{&quot;Jan&quot;, &quot;Feb&quot;, &quot;Mar&quot;, &quot;Apr&quot;, &quot;May&quot;, &quot;Jun&quot;, &quot;Jul&quot;, &quot;Aug&quot;, &quot;Sep&quot;, &quot;Oct&quot;, &quot;Nov&quot;, &quot;Dec&quot;}</code>.</li> <li><code>Year</code> is in the range <code>[1900, 2100]</code>.</li> </ul> <p>Convert the date string to the format <code>YYYY-MM-DD</code>, where:</p> <ul> <li><code>YYYY</code> denotes the 4 digit year.</li> <li><code>MM</code> denotes the 2 digit month.</li> <li><code>DD</code> denotes the 2 digit day.</li> </ul> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> date = &ldquo;20th Oct 2052&rdquo;</p> <p><strong>Output:</strong> &ldquo;2052-10-20&rdquo;</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> date = &ldquo;6th Jun 1933&rdquo;</p> <p><strong>Output:</strong> &ldquo;1933-06-06&rdquo;</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> date = &ldquo;26th May 1960&rdquo;</p> <p><strong>Output:</strong> &ldquo;1960-05-26&rdquo;</p> <p><strong>Constraints:</strong></p> <ul> <li>The given dates are guaranteed to be valid, so no error handling is necessary.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details