0% found this document useful (0 votes)
10 views

mad microproject date time

The document is a report on the implementation of a Date and Time Picker for mobile applications, submitted to the Maharashtra Board of Technical Education by students of Y.B. Patil Polytechnic, Akurdi Pune. It outlines the importance of date and time selection in Android apps, the technology used, advantages, and applications of the feature. The report includes source code examples and concludes with the significance of enhancing user experience through effective time-based input methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

mad microproject date time

The document is a report on the implementation of a Date and Time Picker for mobile applications, submitted to the Maharashtra Board of Technical Education by students of Y.B. Patil Polytechnic, Akurdi Pune. It outlines the importance of date and time selection in Android apps, the technology used, advantages, and applications of the feature. The report includes source code examples and concludes with the significance of enhancing user experience through effective time-based input methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Y. B.

PATIL POLYTECHNIC, AKURDI PUNE

SUBMITTED TO

MAHARASHTRA BOARD OF TECHNICAL EDUCTAION

Mobile Application Development (MAD)


(22617)

Report On
Date and Time Picker

Under Guidance Of
Mr. Swami Sir

Diploma in Computer Engineering


2024–2025(Semester–6)
Y.B. Patil Polytechnic, Akurdi Pune
Third Year, Department of Computer Engineering
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

CERTIFICATE:

This is to certify that:

Roll No. Name

of Sixth Semester Diploma in Computer Engineering Section A in Y.B. Patil Polytechnic,


Akurdi has completed the Micro Project satisfactory in Subject MAD for the academic Year
2024–2025 as prescribed in the MSBTE Curriculum

Subject Teacher HOD Principal


Mr. Swami Sir Mrs. Pooja Ahuja Dr. A. S. Kondekar
ACKNOWLEDGEMENT:

We would like to express our special thanks of gratitude to Swami Sir who gave us a
golden opportunity to showcase and let us learn more about our topic i.e. "Date And Time
Picker" and also taught us the way to work in a team. We would also like to underscore
dynamic efforts of the teamwork, and their expert advice to complete this project in
time.

Date: Place: Akurdi, Pune


INDEX:
INTRODUCTION:

In modern Android applications, selecting the correct date and time is a crucial feature for
scheduling events, setting reminders, and managing time-sensitive tasks. Android Studio
provides built-in Date Picker and Time Picker widgets that allow users to pick a date or
time through an intuitive and user-friendly interface. These pickers can be implemented using
dialogs or inline widgets, offering flexibility based on the app's requirements. By integrating
date and time pickers, developers can enhance user experience and ensure accurate time-
based inputs in their applications.
Key Features:
 User-Friendly Interface: Provides an intuitive way for users to select dates and
times.
 Customization Options: Can be customized with different themes, styles, and
formats.
 Dialog or Inline Picker: Can be displayed as a pop-up dialog or an embedded
widget.
 Validation & Restrictions: Allows setting min/max dates, disabling past or future
dates, and preventing invalid selections.
 24-hour & 12-hour Format Support: Users can choose between AM/PM or 24-hour
time formats.
 Seamless Integration: Can be easily integrated with other UI components like
buttons and text fields.

Why Build a Date and Time Picker?


 Essential for Scheduling: Useful in apps requiring appointment booking, event
scheduling, or reminders.
 Improves User Experience: Provides a structured and easy way to input date and
time.
 Reduces Errors: Eliminates the need for manual date/time entry, reducing user
mistakes.
 Enhances App Functionality: Increases the efficiency of applications requiring time-
sensitive inputs.

Technology Used:
 Android Studio: Primary IDE for developing Android apps.
 Kotlin/Java: Programming languages used for implementing date and time pickers.
 XML: Used for designing UI layouts.
 Android SDK Components: Provides built-in DatePicker and TimePicker classes.
Advantages:
 Prebuilt UI Components: Saves development time as Android provides built-in
pickers.
 Customizable & Flexible: Can be tailored to match the app's design and
functionality needs.
 Error Reduction: Prevents invalid date/time entries.
 Efficient Scheduling: Useful for apps requiring precise date and time input.

Applications:
 Calendar and Scheduling Apps: Google Calendar, Outlook, and task management
apps.
 Booking Applications: Hotel, flight, and appointment booking apps.
 Reminders & Alarms: To-do lists, alarms, and medication reminder apps.
 E-commerce & Delivery Apps: Selecting delivery dates and times.
 Event Management: RSVP and event planning apps.
Source Code:

activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:background="@android:color/darker_gray">

<!-- Title TextView -->


<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date &amp; Time Picker"
android:textSize="22sp"
android:textStyle="bold"
android:textColor="@android:color/black"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>

<!-- Date Display TextView -->


<TextView
android:id="@+id/date_display"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Selected Date"
android:textSize="18sp"
android:textColor="@android:color/black"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp"/>

<!-- Date Picker Button -->


<Button
android:id="@+id/date_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pick Date"
android:textSize="16sp"
app:layout_constraintTop_toBottomOf="@id/date_display"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="8dp"/>

<!-- Time Display TextView -->


<TextView
android:id="@+id/time_display"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Selected Time"
android:textSize="18sp"
android:textColor="@android:color/black"
app:layout_constraintTop_toBottomOf="@id/date_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="16dp"/>

<!-- Time Picker Button -->


<Button
android:id="@+id/time_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pick Time"
android:textSize="16sp"
app:layout_constraintTop_toBottomOf="@id/time_display"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="8dp"/>

</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java:
package com.example.demo1;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Calendar;
public class MainActivity extends AppCompatActivity {

private TextView dateDisplay, timeDisplay;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// Initialize the TextViews


dateDisplay = findViewById(R.id.date_display);
timeDisplay = findViewById(R.id.time_display);

// Date Picker Button


Button dateButton = findViewById(R.id.date_button);
dateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showDatePicker();
}
});

// Time Picker Button


Button timeButton = findViewById(R.id.time_button);
timeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showTimePicker();
}
});
}

// Method to show the DatePickerDialog


private void showDatePicker() {
// Get the current date
final Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);

// Create and show the DatePickerDialog


DatePickerDialog datePickerDialog = new DatePickerDialog(
this,
(view, selectedYear, selectedMonth, selectedDayOfMonth) -> {
// Display the selected date
dateDisplay.setText("Selected Date: " + selectedDayOfMonth + "/" +
(selectedMonth + 1) + "/" + selectedYear);
},
year, month, dayOfMonth
);
datePickerDialog.show();
}

// Method to show the TimePickerDialog


private void showTimePicker() {
// Get the current time
final Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
// Create and show the TimePickerDialog
TimePickerDialog timePickerDialog = new TimePickerDialog(
this,
(view, selectedHour, selectedMinute) -> {
// Display the selected time
timeDisplay.setText("Selected Time: " + selectedHour + ":" + (selectedMinute <
10 ? "0" + selectedMinute : selectedMinute));
},
hour, minute, true // 'true' for 24-hour format
);
timePickerDialog.show();
}
}
Output:
Conclusion:

Implementing a Date and Time Picker in Android Studio enhances the usability and
efficiency of applications that require precise time-based inputs. With built-in support for
intuitive UI components, customization options, and seamless integration, these pickers
provide a structured and error-free way for users to select dates and times. Whether for
scheduling, reminders, or event management, the Date and Time Picker plays a crucial role in
improving user experience. By leveraging Android's powerful SDK and UI tools, developers
can create feature-rich applications that cater to various time-sensitive functionalities
effectively.

You might also like