03-16-2011 05:49 AM
Hi
I am working on 5.0 jde and i use datePicker in an application.But the Datepicker is not working properly.The "ok" and "Cancel" button is not working in the right way.If i click on the cancel button even then it select the date of the datepicker
My code is following--
DateTimePicker datePicker = DateTimePicker.createInstance(Calendar.getInstance
datePicker.doModal();
Calendar cal = datePicker.getDateTime();
int month=cal.get(cal.MONTH);
int year=cal.get(cal.YEAR);
int date1=cal.get(cal.DATE);
03-16-2011 09:25 AM
doModal() returns true if the user selected OK and false if it was Cancel, so you need to be testing it.
03-16-2011 01:24 PM
Such as
DateTimePicker datePicker = DateTimePicker.createInstance(Calendar.getInstance(), "yyyy-MM-dd", null); if(datePicker.doModal()) { Calendar cal = datePicker.getDateTime(); int month=cal.get(cal.MONTH); int year=cal.get(cal.YEAR); int date1=cal.get(cal.DATE); }
04-29-2011 08:07 AM
Hello sir i m using date picker in which i have to send from and to date to server ..
now by using the date picker i m getting date in this format ::: From Date :::net.rim.device.impl.ui.picker.datetime.DateTime
that date in yyddmm format ...please tell me how to solve this problem i m using the following code:::
this the post date in which i have to send from and to date ...
please tell me the solution ...
with regards
04-29-2011 09:47 AM
You need to use DateTimePicker.getDateTime(), which will return you a Calendar object. From there you can use some formatter (SimpleDateFormat will probably work) to get the date output the way you want.
04-30-2011 01:26 AM
Hi,
Check this code i hope this code usefull to...
DateTimePicker datePicker = DateTimePicker.createInstance();
datePicker.doModal();
Calendar cal = datePicker.getDateTime();
Date date = cal.getTime();
SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd hh:mm"); date1=format.format(date);
--------------------------------------------------
feel free to press the kudos button
on the left side to thank the user that helped you.
please mark posts as solved if you found a solution
06-19-2011 09:05 PM
That may have been in the past.
int doModal() now returns type int. 0 indicates the user selected OK.