Day Of Year To Day Of Month Program in java

  1. import java.util.Calendar;  
  2.    
  3. public class DayYearToDayMonth   
  4. {  
  5.     public static void main(String[] args)  
  6.     {       
  7.         Calendar calendar = Calendar.getInstance();  
  8.         calendar.set(Calendar.YEAR, 2007);  
  9.         calendar.set(Calendar.DAY_OF_YEAR, 181);  
  10.         System.out.println("\nThe date of Calendar is: " + calendar.getTime());  
  11.         int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);    
  12.         System.out.println("The day of month: " + dayOfMonth);    
  13.         int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);  
  14.         System.out.println("The day of week: " + dayOfWeek);  
  15.     }