Day Of Year To Day Of Week Program in java

  1. import java.util.Calendar;   
  2. public class DayOfYearToDayOfWeek{  
  3.     public static void main(String[] args){  
  4.         Calendar calendar = Calendar.getInstance();  
  5.         for(int i=2000;i<2025;i++){  
  6.         calendar.set(Calendar.YEAR, i);  
  7.         calendar.set(Calendar.DAY_OF_YEAR,0);  
  8.         System.out.println(calendar.getTime().toString());  
  9.         int weekday = calendar.get(Calendar.DAY_OF_WEEK);  
  10.         System.out.println("Weekday: " + weekday);  
  11.         System.out.println();  
  12.         }  
  13.     }