1import java.util.*;
2import java.text.SimpleDateFormat;
3import java.text.DateFormat;
4
5
6public class GetDayName {
7
8 public static void main(String[] args) {
9 Date date1 =
10 (new GregorianCalendar
11 (1989, Calendar.OCTOBER, 17)).getTime();
12 Date date2 = new Date();
13 System.out.println
14 ("1989-10-17 was a " + sayDayName(date1));
15 System.out.println("Today is a " + sayDayName(date2));
16 }
17
18 public static String sayDayName(Date d) {
19 DateFormat f = new SimpleDateFormat("EEEE");
20 try {
21 return f.format(d);
22 }
23 catch(Exception e) {
24 e.printStackTrace();
25 return "";
26 }
27 }
28}