Class Solution
-
- All Implemented Interfaces:
public final class Solution3280 - Convert Date to Binary.
Easy
You are given a string
daterepresenting a Gregorian calendar date in theyyyy-mm-ddformat.datecan be written in its binary representation obtained by converting year, month, and day to their binary representations without any leading zeroes and writing them down inyear-month-dayformat.Return the binary representation of
date.Example 1:
Input: date = "2080-02-29"
Output: "100000100000-10-11101"
Explanation:
100000100000, 10, and 11101 are the binary representations of 2080, 02, and 29 respectively.
Example 2:
Input: date = "1900-01-01"
Output: "11101101100-1-1"
Explanation:
11101101100, 1, and 1 are the binary representations of 1900, 1, and 1 respectively.
Constraints:
date.length == 10date[4] == date[7] == '-', and all otherdate[i]'s are digits.The input is generated such that
daterepresents a valid Gregorian calendar date between Jan 1<sup>st</sup>, 1900 and Dec 31<sup>st</sup>, 2100 (both inclusive).
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final StringconvertDateToBinary(String dat)-
-
Method Detail
-
convertDateToBinary
final String convertDateToBinary(String dat)
-
-
-
-