获得约会和时间黑莓中日期时间选择器的时间值

时间:2012-03-21 05:02:23

标签: blackberry

我使用日期&黑莓时间选择器。   我想显示所选日期&在一个领域的时间。   这是我正在使用的代码。

            DateTimePicker datePicker = DateTimePicker.createInstance();
            datePicker.doModal();
            Calendar cal = datePicker.getDateTime();
            Date date = cal.getTime();

1 个答案:

答案 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)      

        }

    }
});