cancel
Showing results for 
Search instead for 
Did you mean: 

how to capture the presnt year and month .Urgent!!

Former Member
0 Kudos

Hi all,

I need to take the present year and month from the system and have to populate in drodownlists. can any one help me how to get these two seperatly and populate. xxxxxx (please read forum rules)

regards,

Sharan

Edited by: Armin Reichert on Jan 17, 2008 10:23 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Use

Calendar cal = Calendar.getInstance();

cal.get(Calendar.YEAR); // Year

cal.get(Calendar.MONTH) // Month

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html

Regards

Ayyapparaj

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You can get the current year and month using the following code:

Date curr = new Date(System.currentTimeMillis());

int year = curr.getYear();

int month = curr.getMonth();

This two things you can poulate into an array and then to the attribute of your dropdownlist.

thanks & regards,

Manoj

Former Member
0 Kudos

Hi,

If you are using DropDownByKey UI elements:

1. Let's say the context attributes bound to the selectedKey property are called year and month respectively.

2. To populate year:

-


Date current = new Date(System.currentTimeMillis());

IWDAttributeInfo attinfo = wdContext.getNodeInfo().getAttribute(IContextElement.YEAR);

ISimpleTypeModifiable modinfo = attinfo.getModifiableSimpleType();

IModifiableSimpleValueSet valset = modinfo.getSVServices().getModifiableSimpleValueSet();

valset.put("currYear",String.valueOf(current.getYear));

-


3. You can do a similar thing for month.

Regards,

Satyajit.