|
2 | 2 |
|
3 | 3 | importjava.util.Calendar; |
4 | 4 |
|
5 | | -/** |
6 | | - * 1154. Day of the Year |
7 | | - * |
8 | | - * Given a string date representing a Gregorian calendar date formatted as YYYY-MM-DD, return the day number of the year. |
9 | | - * |
10 | | - * Example 1: |
11 | | - * |
12 | | - * Input: date = "2019-01-09" |
13 | | - * Output: 9 |
14 | | - * Explanation: Given date is the 9th day of the year in 2019. |
15 | | - * Example 2: |
16 | | - * |
17 | | - * Input: date = "2019-02-10" |
18 | | - * Output: 41 |
19 | | - * Example 3: |
20 | | - * |
21 | | - * Input: date = "2003-03-01" |
22 | | - * Output: 60 |
23 | | - * Example 4: |
24 | | - * |
25 | | - * Input: date = "2004-03-01" |
26 | | - * Output: 61 |
27 | | - * |
28 | | - * Constraints: |
29 | | - * |
30 | | - * date.length == 10 |
31 | | - * date[4] == date[7] == '-', and all other date[i]'s are digits |
32 | | - * date represents a calendar date between Jan 1st, 1900 and Dec 31, 2019. |
33 | | - * */ |
34 | 5 | publicclass_1154 { |
35 | 6 | publicstaticclassSolution1 { |
36 | 7 | Calendarcal =Calendar.getInstance(); |
|