Package COM. itheima; import Java. util. calendar; import Java. util. date; import Java. util. gregoriancalendar; import Java. util. week; public class test {public static void main (string ARGs []) {calculate () ;}// you can use the calendar ar object to conveniently find the day of a week in a year, and calculate the day of the year as public static void calculate () {// obtain the input result scanner S = new partition (system. in); // string split string [] Date = S. nextline (). split ("-"); // construct the Calendar Object gregoriancalendar calendar = new gregoriancalendar (integer. parseint (date [0]), integer. parseint (date [1])-1, integer. parseint (date [2]); // obtain the result system. out. println ("the day of the year" + calendar. get (calendar. day_of_year) + "day"); system. out. println ("Week:" + (calendar. get (calendar. day_of_week)-1 ));}}
The date and calendar classes of the dark horse self-learning videos