Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
Jutikorn
Posts: 58
Registered: ‎10-21-2010
My Device: Bold 9700
My Carrier: DTAC
Accepted Solution

Getting selected date from DateField?

I have my DateField was set like this:

 

 

SimpleDateFormat dmy = new SimpleDateFormat("yyyy MM dd");
	DateField depart = new DateField(str_depart, System.currentTimeMillis(), dmy);

 It's shown:

 

2011 05 04

 I want to get the selected date from this field and I use getDate(); method that return Long type (1304485459386).

How can I do to convert it to String and show 2011 05 04 ?

 

Thanks 

Regards.

 

 

Please use plain text.
Developer
girishthakr
Posts: 232
Registered: ‎12-15-2008
My Device: 9700
My Carrier: Vodafone India

Re: Getting selected date from DateField?

hey do this...

 

String dateSelected  = depart.toString();

 

System.out.println("Date selected is .... "+dateSelected );

 

Don't forget to give Kudos and resolve this thread if solved... :smileyhappy:

Please use plain text.
Regular Contributor
Jutikorn
Posts: 58
Registered: ‎10-21-2010
My Device: Bold 9700
My Carrier: DTAC

Re: Getting selected date from DateField?

[ Edited ]

Thank you so much !!  girishthakr 

Please use plain text.
Developer
shahumang8
Posts: 643
Registered: ‎08-09-2010
My Device: Not Specified

Re: Getting selected date from DateField?

Hi,

check this code 

 

 

DateTimePicker datePicker = DateTimePicker.createInstance();				                datePicker.doModal();
Calendar cal = datePicker.getDateTime();
Date date = cal.getTime();
SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd hh:mm");
String 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

Please use plain text.