Android Date and Time Picker Dialog

Android Date and Time Picker Dialog

Date Picker Dialog and Time Picker Dialog in Android use to select a date and time, as it will be popup when you needed. While Time Picker and Date Picker widget occupy more space on screen. Dialogs are best way to solve this issue.


In this tutorial, we are going to demonstrate the use of Date Picker through DatePickerDialog and TimePicker through TimePickerDialog.


1. Create a new project in Eclipse by navigating to File ⇒ New Android ⇒ Application Project and fill required details. (I kept my main activity name as

2. First create a simple layout as shown in video. The layout contains two buttons and two hidden textviews. The layout name is activity_main.xml.

3. Now add the following code to your In this code i showed how to display the time and date dialog box and get the selected date and time from dialog and show on textViews.

4. That’s all  –  run the app and you will get the output as shown in video.

Thanks. :)

Download Source Code


About the author

I am an Android developer for whom Android is the one and only love. I work as a freelancer which gets me and Android closer. I always love to share my learnings and love to learn from others knowledge too.


its not workinggg

    Hi Jawaher,

    Can you tell me what issue you are facing?


Leave a Comment

Comment (required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Name (required)
Email (required)