0

I am receiving date and time in the format of 13/10/26 20:02. I like to change that format to the new format as "EEE,d MMM yyyy,HH:mm:ss". What could be the best way to do that?

EDIT1:

Now I tried as follow

String date = "26/10/2013 20:55"; 
SimpleDateFormat df = new SimpleDateFormat("EEE,d MMM yyyy,HH:mm:ss"); 
String newdateformat = df.format(Date.parse(date)); 

But now newdateformat is "Tue,10 Feb 2015,20:55:00"; Why the date is wrong? Thanks

batuman
  • 7,066
  • 26
  • 107
  • 229

3 Answers3

3

You can use the following:

SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy  hh:mm a");
String date = sdf.format(Date.parse("Your date")); 
Rishabh Srivastava
  • 3,683
  • 2
  • 30
  • 58
0

to change the format of the date in android, try this code

 SimpleDateFormat formatter = new SimpleDateFormat(dd/mm/yyyy hh:mm:ss a");

    Date date=new Date();
    String newDate =formatter.format(date.getTime()); 

    Toast.makeText(this,newDate, Toast.LENGTH_SHORT).show();
Nambi
  • 11,944
  • 3
  • 37
  • 49
0

Try this one

    SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMMM yyyy, HH:mm:ss");
    Date date = new Date(your date);
    String date_format = sdf.format(date);

hope this will help

Aravin
  • 4,126
  • 1
  • 23
  • 39