Question Detail

How to get Date, Day, Month and Year in android?

6 years ago Views 1257 Visit Post Reply

I have a list where is I am showing Date in formatting.
but I am not able to show Day Month year and Date separately please help me.
How can I  do use Date in a formatted way?

Thread Reply

Nick Johnson

- 6 years ago

import android.text.format.DateFormat;

String dayOfTheWeek = (String) DateFormat.format("EEEE", date); // Thursday
String day          = (String) DateFormat.format("dd",   date); // 20
String monthString  = (String) DateFormat.format("MMM",  date); // Jun
String monthNumber  = (String) DateFormat.format("MM",   date); // 06
String year         = (String) DateFormat.format("yyyy", date); // 2013