find Week of Month in java


import java.util.Calendar;

public class WeekOfMonth {

    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);

        int WEEK_OF_MONTH=ca1.get(Calendar.WEEK_OF_MONTH);
        System.out.println("Week of Month :"+WEEK_OF_MONTH);

        // 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 DAY_OF_YEAR=ca1.get(Calendar.DAY_OF_YEAR);
        int WEEK_OF_YEAR=ca1.get(Calendar.WEEK_OF_YEAR);
        */
    }
}

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|