fork download
  1. import java.util.Scanner;import java.text.*;class D{
  2. /* I had to accept input via stdin, so I wrote another main method that passes values to the
  3. * main method seen in my answer. The main method in my answer is now called MAIN.
  4. * This acts exactly the same way that it would from inserting command line arguments.
  5. */
  6. public static void main(String[]a){MAIN(new String[]{new Scanner(System.in).nextLine()});}
  7. public static void MAIN(String[]a){long y=new Long(a[0]);int i=0;for(;!s(y).equals(s(y+(++i))););System.out.printf("Advance Happy New Year, %d (%s)",y+i,s(y+i));}static String s(long y){try{return new SimpleDateFormat("E").format(new SimpleDateFormat("d/M/yyyy").parse("1/1/"+y));}catch(Exception e){}return"";}}
Success #stdin #stdout 0.17s 321344KB
stdin
2001
stdout
Advance Happy New Year, 2007 (Mon)