-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDayOfWeek.java
More file actions
26 lines (17 loc) · 757 Bytes
/
Copy pathDayOfWeek.java
File metadata and controls
26 lines (17 loc) · 757 Bytes
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
import java.util.Scanner;
import java.util.Calendar;
import java.text.DateFormatSymbols;
public class DayOfWeek{
public static void main(String[] args){
Scanner birth = new Scanner(System.in);
System.out.println("How many years do you want to go back?\n");
String input = birth.nextLine();
int i = Integer.parseInt(input);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.YEAR, - i);
int weekday = calendar.get(Calendar.DAY_OF_WEEK);
DateFormatSymbols dd = new DateFormatSymbols();
String results = dd.getWeekdays()[weekday];
System.out.println(i + " years ago, it was a " + results + ".");
}
}