import java.util.Calendar;
public class DayOfYear {
public static void main(String[] args) {
Calendar ca1 = Calendar.getInstance();
/*
set(int year, int month, int date)
Jan=0,Feb=1,Mar=2...
*/
ca1.set(2009,4,22);
/*
2 Feb 2009, Day of Year, Jan 31 + 2 Feb =33 day of year
*/
int DAY_OF_YEAR=ca1.get(Calendar.DAY_OF_YEAR);
System.out.println("Day of Year :"+DAY_OF_YEAR);
// More Calendar Date option can check
/*
int DAY_OF_MONTH=ca1.get(Calendar.DAY_OF_MONTH);
int DAY_OF_WEEK=ca1.get(Calendar.DAY_OF_WEEK);
int WEEK_OF_MONTH=ca1.get(Calendar.WEEK_OF_MONTH);
int WEEK_OF_YEAR=ca1.get(Calendar.WEEK_OF_YEAR);
*/
}
}
0 comments:
Post a Comment