Sponser Link

How to Get current date and time in android programmatically.

In this article we will use calendar class for get current date and time and display into text view. GetCurrentDate() function will return the current date time in string.

private String GetCurrentDate()


String str_date="";

    Calendar c = Calendar.getInstance();

        SimpleDateFormat df = new SimpleDateFormat("EEE : dd MMM yyyy/");

        String formattedDate = df.format(c.getTime());

        // formattedDate have current date/time


      return str_date;


You can call GetCurrentDate()in your code where you need set date and time in textview.

TextView lblDate=(TextView)findViewById(R.id.lblDate);