tags:

views:

608

answers:

1

Hi ,

I have a date picker and a time picker in my app. Can anyone tell me how to get the values of the date and time that are selected??? What i mean to say is, for EditText we can declare as

final EditText Name = (EditText) this.findViewById(R.id.nametext); 

and we can cast the data of it by using Name.getText().toString().

So similarly how can we get the values of date picker and time picker to a string???

+2  A: 

DatePicker has

getYear() 
getMonth() 
getDayOfMonth()

to make a Date object from a DatePicker you'd do new Date(datePicker.getYear() - 1900, datePicker.getMonth(), datePicker.getDayOfMonth());

TimePicker has

getCurrentHour()
getCurrentMinute()
Jim Blackler
Can u plz provide an example??? i am getting an error while initializing the date and time objects
Rahul Varma