Reputation: 7304
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
Upvotes: 0
Views: 2194
Reputation: 3745
You can use the following:
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy hh:mm a");
String date = sdf.format(Date.parse("Your date"));
Upvotes: 3
Reputation: 4108
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
Upvotes: 0
Reputation: 12042
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();
Upvotes: 0