5 Replies Latest reply: Aug 31, 2007 8:42 AM by 807605 RSS

    java.util.Calendar from Date or String

    807605
      Hi,

      I'm using JXDatePicker in order to let user choose a date.
      Now, I would like to get int value representing the day of week.

      I know that I can do it this way:
      Calendar cal = new GregorianCalendar(<year>, Calendar.<month>, <day>);
          int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); 
      But I would prefer to do it using a Date or String object.

      I tried:
      cal.setTime(<date>);

      where date is a Date object retrieved directly from JXDatePicker but cal.DAY_OF_WEEK always returns value for current date (it means for today).

      How can I set up Calendar object using Date or String in order to get day of week?

      Regards,
      Stanley

      null