-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSolution.java
More file actions
49 lines (38 loc) · 2.11 KB
/
Solution.java
File metadata and controls
49 lines (38 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// [A Psalm] of David. I will praise thee with my whole heart: before the gods will I sing praise unto thee.
// I will worship toward thy holy temple, and praise thy name for thy lovingkindness and for thy truth:
// for thou hast magnified thy word above all thy name (Psalm 138:1)
package com.javarush.task.task40.task4009;
import java.time.LocalDate;
import java.time.Year;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
import java.time.format.FormatStyle;
/*
Buon Compleanno!
*/
public class Solution {
public static void main(String[] args) {
System.out.println(weekDayOfBirthday("30.05.1984", "2015"));
}
public static String weekDayOfBirthday(String birthday, String year) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("d.M.yyyy", Locale.ITALIAN); //напишите тут ваш код
LocalDate localDate = LocalDate.parse(birthday, dateTimeFormatter);
localDate = localDate.with(Year.parse(year));
return DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL).withLocale(Locale.ITALIAN).format(localDate).split(" ")[0];
}
}
/*
Buon Compleanno!
Реализуй метод weekDayOfBirthday.
Метод должен возвращать день недели на итальянском языке, в который будет (или был) день рождения в определенном году.
Пример формата дат смотри в методе main.
Пример:
1) Для "30.05.1984" и "2015" метод должен вернуть: sabato
2) Для "1.12.2015" и "2016" метод должен вернуть: gioved?
Выполни задание, используя Java 8 DateTime API.
Требования:
1. Используй статический метод parse класса LocalDate.
2. Используй статический метод parse класса Year.
3. Используй локаль Locale.ITALIAN.
4. Метод weekDayOfBirthday должен возвращать правильный день недели для передаваемых параметров.
*/