SHARE
TWEET

Untitled

a guest Jun 19th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ java Foo
  2. Sun Oct 31 17:59:44 EET 2010
  3. Sun Oct 31 17:59:44 EET 2004
  4. Sun Oct 31 17:59:44 EET 1999
  5. Sun Oct 31 17:59:44 EET 1993
  6. Sun Oct 31 17:59:44 EET 1982
  7.  
  8.  
  9.  
  10. import java.util.*;
  11.  
  12. public class Foo {
  13.  
  14.   public static void main(String[] args) {
  15.  
  16.     Calendar cal = Calendar.getInstance();
  17.     cal.setTime(new Date());
  18.  
  19.     for (int year = 2010; year > 1980; year--) {
  20.       cal.set(Calendar.YEAR, year);
  21. //      for (int i = 11; i > 0; i--) {
  22.   //      cal.set(Calendar.MONTH, i);
  23.         cal.set(Calendar.MONTH, Calendar.OCTOBER);
  24.         int fridays = 0;
  25.         int saturdays = 0;
  26.         int sundays = 0;
  27.         int first = cal.getActualMinimum( Calendar.DAY_OF_MONTH );
  28.         int last = cal.getActualMaximum( Calendar.DAY_OF_MONTH );
  29.  
  30.         for (int j = first; j <= last; j++) {
  31.           cal.set(Calendar.DAY_OF_MONTH , j);  
  32.           if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY)
  33.             fridays++;
  34.           if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
  35.             saturdays++;
  36.           if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
  37.             sundays++;
  38.         }
  39.         if (fridays == 5 && saturdays == 5 && sundays == 5)
  40.           System.out.println(cal.getTime());
  41.     //  }
  42.     }
  43.   }
  44. }
RAW Paste Data
Top