Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    33

    Unanswered: To Find out Date by inputting Week

    hi all

    Here i have a query in java.

    I have a selection list for week name,

    say Week1, Week2, Week3 etc.. and a month selection list for a particular month. User will select a month and a week (say Week2) and clicks on submit button. Based on this week, i have to extract Day and Month and pass as parameter to action page.

    How to find out the date for a given week and month in java or javascript.


    Thanks in advance

  2. #2
    Join Date
    Oct 2003
    Posts
    5

    Re: To Find out Date by inputting Week

    Use the java.util.Calendar class. Something like:

    public static void main(String[] args)
    {
    //
    // This will give you a Calendar representing the Date right now.
    Calendar c = Calendar.getInstance();

    //
    // Set the MONTH field to the desired month.
    // Use Calendar.JANUARY, Calendar.FEBRUARY, etc.,
    // or use a number (0=Jan, 1=Feb, etc).
    c.set(Calendar.MONTH, Calendar.FEBRUARY);

    //
    // Set the week of the month.
    c.set(Calendar.WEEK_OF_MONTH, 1);

    System.out.println("Date is: " + c.getTime());
    }

    You'll have to do a bit of checking for days in the first and last week of the month. For example, if you set the Calendar to have a YEAR=2003, MONTH=NOVEMBER, WEEK_OF_MONTH=1, DAY_OF_WEEK=FRIDAY it will return October 31.

    Good luck.
    - Egan


    Originally posted by kondaoracle
    hi all

    Here i have a query in java.

    I have a selection list for week name,

    say Week1, Week2, Week3 etc.. and a month selection list for a particular month. User will select a month and a week (say Week2) and clicks on submit button. Based on this week, i have to extract Day and Month and pass as parameter to action page.

    How to find out the date for a given week and month in java or javascript.


    Thanks in advance

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •