Reputation: 4905
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.
Upvotes: 0
Views: 2252
Reputation: 3294
You probably want to use DateTimePicker
. That way you don't have to go through the hassle of creating a DateField
and adding it to a Dialog
.
DateTimePicker datePicker = DateTimePicker.getInstance();
datePicker.doModal();
Calendar cal = datePicker.getDateTime();
Upvotes: 0
Reputation: 2138
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
Upvotes: 2