cornercorner
FeaturesPluginsDocs & SupportCommunityPartners

VwpFAQInputCalDOM

Revision as of 18:13, 5 November 2009 by Admin (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)

Calendar: How do I extract DAY_OF_MONTH from the Calendar component?

Here's a simple example:

1. Drag a button, 2 staticText fields, and a calendar onto the designer
2. Double click the button and add the following source to the action() method:

          java.util.Date chosenDate = calendar1.getSelectedDate();
          java.util.Calendar calDate = java.util.Calendar.getInstance();
          calDate.setTime(chosenDate);
          java.util.Calendar gregDate = new java.util.GregorianCalendar();
          gregDate.setTime(chosenDate);
          staticText1.setValue(calDate.get(calDate.DAY_OF_MONTH) + "");
          staticText2.setValue(gregDate.get(gregDate.DAY_OF_MONTH) + "");
    3. deploy/run



Select a date from the calendar and press the button. The staticText fields should reflect the day of month selected.