Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ java Foo
- Sun Oct 31 17:59:44 EET 2010
- Sun Oct 31 17:59:44 EET 2004
- Sun Oct 31 17:59:44 EET 1999
- Sun Oct 31 17:59:44 EET 1993
- Sun Oct 31 17:59:44 EET 1982
- import java.util.*;
- public class Foo {
- public static void main(String[] args) {
- Calendar cal = Calendar.getInstance();
- cal.setTime(new Date());
- for (int year = 2010; year > 1980; year--) {
- cal.set(Calendar.YEAR, year);
- // for (int i = 11; i > 0; i--) {
- // cal.set(Calendar.MONTH, i);
- cal.set(Calendar.MONTH, Calendar.OCTOBER);
- int fridays = 0;
- int saturdays = 0;
- int sundays = 0;
- int first = cal.getActualMinimum( Calendar.DAY_OF_MONTH );
- int last = cal.getActualMaximum( Calendar.DAY_OF_MONTH );
- for (int j = first; j <= last; j++) {
- cal.set(Calendar.DAY_OF_MONTH , j);
- if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY)
- fridays++;
- if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
- saturdays++;
- if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
- sundays++;
- }
- if (fridays == 5 && saturdays == 5 && sundays == 5)
- System.out.println(cal.getTime());
- // }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement