Reputation: 3791
In android am getting date in (date = "04-01-2013") this format
but i want to show same date in
en.US format like (date="Friday,January 04,2013")
Upvotes: 0
Views: 987
Reputation: 5183
This is how you do it in java
SimpleDateFormat df=new SimpleDateFormat("EEEE,MMMM dd,yyyy");
java.util.Date date=df.parse("04-01-2013");
refer this
Upvotes: 0
Reputation: 29436
use SimpleDateFormat
.
set input pattern matching input date string: "04-01-2013" -> "dd-MM-yyyy"
.
And output pattern like output: "Friday, January 04, 2013" -> "EEEE, MMMM dd, yyyy"
public String formatDate(String input){
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
Date d = sdf.parse(input);
sdf.applyPattern("EEEE, MMMM dd, yyyy");
return sdf.format(d,new StringBuffer(),0).toString();
}
Upvotes: 2
Reputation: 1479
try {
DateFormat df1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
DateFormat df2 = new SimpleDateFormat("dd-MMM-yyyy");
return df2.format(df1.parse(input));
}
catch (ParseException e) {
return null;
}
Upvotes: 1
Reputation: 15414
You can use something like this
android.text.format.DateFormat.format("EEEE, MMMM dd, yyyy", new java.util.Date());
Take a look at DateFormat.
Upvotes: 0