Tushar
Tushar

Reputation: 5935

Picker for date and time on a BlackBerry

I want to use a date and time picker in a BlackBerry app.

Upvotes: 0

Views: 1112

Answers (3)

8vius
8vius

Reputation: 5836

I don't know if you still have this problem but the solution I used is the DateTimePicker Here's how you do it:

Calendar _dateCal;
SimpleDateFormat _dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
DateTimePicker _datePicker = DateTimePicker.createInstance(_dateCal, "dd-MMM-yyyy", null);

if(_datePicker.doModal())
{
    StringBuffer _dateStr = new StringBuffer();
    _dateCal = _datePicker.getDateTime();
    _dateFormat.format(_dateCal, _dateStr, null);
    _setDateButton.setLabel(_dateStr.toString());
}

That will prompt a spinner box for date selection to the screen

Upvotes: 0

Vit Khudenko
Vit Khudenko

Reputation: 28418

Use net.rim.device.api.ui.component.DateField.

long yourInitialDatetime = System.currentTimeMillis();
DateField dateField = new DateField("Date:", yourInitialDatetime, 
    DateField.DATE_TIME);
yourScreen.add(dateField);
...
long currentlySelectedDatetime = dateField.getDate();

Upvotes: 1

Maksym Gontar
Maksym Gontar

Reputation: 22775

Also, see BlackBerry - Creating custom Date Field

Upvotes: 0

Related Questions