我使用日期&黑莓时间选择器。 我想显示所选日期&在一个领域的时间。 这是我正在使用的代码。
DateTimePicker datePicker = DateTimePicker.createInstance();
datePicker.doModal();
Calendar cal = datePicker.getDateTime();
Date date = cal.getTime();
答案 0 :(得分:4)
DateTimePicker dateTimePicker = DateTimePicker.createInstance(Calendar.getInstance(), null, "HH:mm");
Calendar calendar = Calendar.getInstance();
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
if(dateTimePicker.doModal()) {
calendar = dateTimePicker.getDateTime();
Date date = calendar.getTime();
long longDate = date.getTime();
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
String eventstring = dateFormat.format(date);
Dialog.inform("You have selected time =="+eventstring)
}
}
});