views:

445

answers:

1

Hi All,

In my application screen, i am having a field, where user can to choose his DateOfBirth. I want to popup any built-in "Date" calendar or some built-in Date picker to user, so that it will look professional. As i'm new to this development, i wanted to know there is any code sample available to popoup the built-in Date Picker? Note: I also want to store the selectable Date by user after selecting it in my existing persistent storage.

Thank you for your suggestions.

+2  A: 

For a native date picker, you can use the DateField, such as:

DateField dateField = new DateField("Date of Birth: ",DateField.DATE);

If you want this to 'pop up' you will have to add this to a dialog, unless there is a native component to do this. You can then query this field for its date, it returns a date object:

Date date = dateField.getDate();

See Date Field

Stephan van den Heuvel
Thanks a lot. But when i add this code in my screen VerticalFieldManager, it throws compilation error as 'cannot find symbol constructor DateField(java.lang.String,int) and 'cannot find symbol class Date' even though i have added 'import net.rim.device.api.i18n.DateFormat;' and 'import net.rim.device.api.ui.component.DateField;'. What would the wrong here?
Ok. I resolved it by adding long value in the second parameter. DateField dateField = new DateField("Date of Birth: ",System.currentTimeMillis(),DateField.DATE);