How to display current date and time in android

In this tutorial we will learn how to get the current date and time in android programatically. It will used for setting into event calendars,  saving the date time of a particular event in database etc. For fetching the current date and time in android , we can use Calendar class which will give the instance of system clock of android phone.

Calendar calander = Calendar.getInstance();

Now we need to mention the format of date using SimpleDateFormat class

Here is the function which returns date and time .

public String CurrentDateTime(){
String date = "";
Calendar calander = Calendar.getInstance();
SimpleDateFormat simpledateformat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
date = simpledateformat.format(calander.getTime());
return date;


This function will return the date in string format , you just need to call this function whenever the date and time is required.

String date = CurrentDateTime();

About the author

Hi guys, i am the author of codesfor. I am a B.Tech graduate currently working as an App developer. Apart from job i am a blogger and a freelancer.

Add a Comment

Your email address will not be published. Required fields are marked *