Reputation:
I am stuck in a date format
I want my date should look like this, 18th Mar 2011 and it can be 1st, 2nd,3rd that means I want to resolve all the aspects
Upvotes: 2
Views: 9366
Reputation: 128428
I think you want to change date in a 18th, 2nd, 1st, 3rd dated way, if i am not wrong then you can use simpleDateFormat class to convert date in different formats.
Before using SimpleDateFormat, just refer the SDK documentation: http://developer.android.com/reference/java/text/SimpleDateFormat.html.
To have day number with nd, th, rd (i.e. 2nd, 4th, 3rd, etc.), you can use:
F - day of week in month (Number) - 2 (2nd Wed in July)
(given in the documentation).
For example using SimpleDateFormat:
String dateStr = "03/08/2010";
SimpleDateFormat curFormater = new SimpleDateFormat("dd/MM/yyyy");
Date dateObj = curFormater.parse(dateStr);
SimpleDateFormat postFormater = new SimpleDateFormat("MMMM dd, yyyy");
String newDateStr = postFormater.format(dateObj);
Upvotes: 3
Reputation: 16110
This is the term you are looking for: Quantity Strings (Plurals)
here is a link for it in the documentation: Plurals
Here is a link with examples:
And One more: Android Pluralization not working, need help
Hope this helps. so you just need to reformat the string with the date by using the examples provided and thats it.
Upvotes: 0