0

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

Maksym Gontar
  • 22,765
  • 10
  • 78
  • 114
Tushar
  • 5,907
  • 15
  • 49
  • 81

3 Answers3

1

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();
Maksym Gontar
  • 22,765
  • 10
  • 78
  • 114
Vit Khudenko
  • 28,288
  • 10
  • 63
  • 91
0

Also, see BlackBerry - Creating custom Date Field

Community
  • 1
  • 1
Maksym Gontar
  • 22,765
  • 10
  • 78
  • 114
0

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

8vius
  • 5,786
  • 14
  • 74
  • 136