13

I want to set date in format like this,

Friday, March 4, 2012 3:15 AM

yes I am know about this

   SimpleDateFormat parseFormat = new SimpleDateFormat("MMMM dd,yyyy hh:mm a");
   Date date =new Date();
   String s = parseFormat.format(date);

but I don't know what is option to show day, please help me. Thanks!

Jignesh Ansodariya
  • 12,583
  • 24
  • 81
  • 113

4 Answers4

22
     SimpleDateFormat parseFormat = new SimpleDateFormat("E MMMM dd,yyyy hh:mm a");
     Date date =new Date();
     String s = parseFormat.format(date);

Refer this for more details SimpleDateFormat

Vins
  • 4,089
  • 2
  • 35
  • 50
15

In your format string, use "E" for the short name (Sun, Mon, Tue, etc), or "EEEE" for the full words (Sunday, Monday, Tuesday, etc).

Also, see here.

Community
  • 1
  • 1
Todd Sjolander
  • 1,459
  • 1
  • 15
  • 28
1
public static String currentDateTime(String dateInParse){
    SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd,yyyy hh:mm a");
    Date date = null;
    try
    {
        date = sdf.parse(dateInParse);
    }
    catch(Exception ex)
    {
        ex.printStackTrace();
    }
    SimpleDateFormat formatter = new SimpleDateFormat("EEEE MMMM dd,yyyy hh:mm a");
    String newFormat = formatter.format(date);

    return newFormat ;
}

here dateInParse is your date in string that format is like as sdf.

Zahidul
  • 389
  • 5
  • 15
0

Simply use E as formatter

Ex:

SimpleDateFormat parseFormat = new SimpleDateFormat("EEEE, MMMM dd,yyyy hh:mm a");

Jayabal
  • 3,619
  • 3
  • 24
  • 32