Sign in
Google apps
Main menu
Post a Comment On:
j4neiros
"Five Fridays in July every 823 years == false"
No comments yet. -
1 – 0 of 0
package pkg5fridaysinjuly;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class Main {
private static final int NUMBER_OF_YEARS = 823;
public static void main(String[] args) {
Calendar c = new GregorianCalendar();
int firstYear = c.get(Calendar.YEAR);
int lastYear = firstYear - NUMBER_OF_YEARS;
c.set(firstYear, Calendar.JULY, 1);
System.out.println("Initial: " + firstYear);
System.out.println("Last: " + lastYear);
for (int y = firstYear; y >= lastYear; y--) {
c.set(y, Calendar.JULY, 1);
if (c.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY) {
System.out.println(y + " Found!");
}
}
}
}
posted by J. Ernesto Aneiros at
1:41 PM
on May 24, 2012
Leave your comment
You can use some HTML tags, such as
<b>, <i>, <a>
Choose an identity
Google Account
You will be asked to sign in after submitting your comment.
Name/URL
Comment with your Google account if you’d like to be able to manage your comments in the future. If you comment anonymously, you won’t be able to edit or delete your comment.
Learn more
Name
URL
Anonymous
Comment with your Google account if you’d like to be able to manage your comments in the future. If you comment anonymously, you won’t be able to edit or delete your comment.
Learn more
Please prove you're not a robot
"Five Fridays in July every 823 years == false"
No comments yet. -