Date Picker in Android using Jetpack Compose Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 6 Likes Like Report In Android, a Date Picker is a widget used to select a date from the calendar. When a Date Picker is implemented in an application, the user can select a year, a month, and a day, combining to form date from a calendar-like-looking box. This data is generally needed and collected in applications that require a specific date to book a movie, travel, or hotel booking. Moreover, a Date Picker is also used in reminder or alarm-based applications. In this article, we will show you how you could implement a Date Picker in Android using Jetpack Compose. Step by Step ImplementationStep 1: Create a New Project in Android StudioTo create a new project in the Android Studio, please refer to How to Create a new Project in Android Studio with Jetpack Compose.Step 2: Working with the MainActivity.kt fileGo to the MainActivity.kt file and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.MainActivity.kt: Kotlin package com.geeksforgeeks.demo import android.app.DatePickerDialog import android.content.Context import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.layout.* import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.* import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.* import java.util.* class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { MaterialTheme { // call composable DatePickerExample(LocalContext.current) } } } } // composable with a button @Composable fun DatePickerExample(context: Context) { // Initializing a Calendar val calendar = Calendar.getInstance() // Fetching current year, month and day val year = calendar.get(Calendar.YEAR) val month = calendar.get(Calendar.MONTH) val day = calendar.get(Calendar.DAY_OF_MONTH) calendar.time = Date() // Declaring a string value to store date in string format val date = remember { mutableStateOf("") } // Declaring DatePickerDialog and setting initial values as current values (present year, month and day) val datePicker = DatePickerDialog( context, { _, mYear, mMonth, mDayOfMonth -> date.value = "$mDayOfMonth-${mMonth + 1}-$mYear" }, year, month, day ) Column( modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally ) { // Creating a button that onClick displays the DatePickerDialog Button( onClick = { datePicker.show() }, colors = ButtonDefaults.buttonColors(containerColor = Color(0XFF0F9D58)) ) { Text( text = "Open Date Picker", color = Color.White ) } // Adding a space of 100dp height Spacer(modifier = Modifier.size(20.dp)) // Displaying the mDate value in the Text Text( text = "Selected Date: ${date.value}", fontSize = 16.sp, textAlign = TextAlign.Center ) } } Output: Create Quiz Comment A aashaypawar Follow 6 Improve A aashaypawar Follow 6 Improve Article Tags : Kotlin Android-Jetpack Explore OverviewIntroduction to Kotlin4 min readKotlin Environment setup for Command Line2 min readKotlin Environment setup with Intellij IDEA2 min readHello World program in Kotlin2 min readBasicsKotlin Data Types3 min readKotlin Variables2 min readKotlin Operators4 min readKotlin Standard Input/Output4 min readKotlin Type Conversion2 min readKotlin Expression, Statement and Block4 min readControl FlowKotlin if-else expression4 min readKotlin while loop2 min readKotlin do-while loop2 min readKotlin for loop4 min readKotlin when expression6 min readKotlin Unlabelled break4 min readKotlin labelled continue4 min readArray & StringKotlin Array6 min readKotlin String4 min readFunctionsKotlin functions7 min readKotlin Default and Named argument7 min readKotlin Recursion3 min readKotlin Tail Recursion2 min readKotlin Lambdas Expressions and Anonymous Functions6 min readKotlin Inline Functions5 min readKotlin infix function notation5 min readKotlin Higher-Order Functions6 min readCollectionsKotlin Collections6 min readKotlin list : Arraylist6 min readKotlin list : listOf()7 min readKotlin Set : setOf()4 min readKotlin hashSetOf()4 min readKotlin Map : mapOf()5 min readKotlin Hashmap7 min readOOPs ConceptKotlin Class and Objects4 min readKotlin Nested class and Inner class3 min readKotlin Setters and Getters4 min readKotlin Class Properties and Custom Accessors3 min readKotlin Constructor6 min readKotlin Visibility Modifiers6 min readKotlin Inheritance10 min readKotlin Interfaces7 min readKotlin Data Classes3 min readKotlin Sealed Classes4 min readKotlin Abstract class5 min readEnum Classes in Kotlin4 min readKotlin extension function4 min readKotlin generics6 min readException HandlingKotlin Exception Handling - try, catch, throw and finally5 min readKotlin Nested try block and multiple catch block3 min readNull SafetyKotlin Null Safety7 min readKotlin Type Checking and Smart Casting3 min readKotlin Explicit Type Casting3 min readRegex & RangesKotlin Regular Expression4 min readKotlin Ranges3 min read Like