I get from the user, the date he sets in a DatePickerDialog. The date i get is in this format:
int selectedYear, int selectedMonth, int selectedDay
Can i format it to be like this "Day, Month dd, yyyy" as shown in the picture below?
Press CTRL+1. In the Format Cells box, click the Number tab. In the Category list, click Date, and then choose a date format you want in Type.
SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. It allows for formatting (date -> text), parsing (text -> date), and normalization. SimpleDateFormat allows you to start by choosing any user-defined patterns for date-time formatting.
Using the values returned from picker
int selectedYear = 2013;
int selectedDay = 20;
int selectedMonth = 11;
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, selectedYear);
cal.set(Calendar.DAY_OF_MONTH, selectedDay);
cal.set(Calendar.MONTH, selectedMonth);
String format = new SimpleDateFormat("E, MMM d, yyyy").format(cal.getTime());
You can Try This:
SimpleDateFormat sdf = new SimpleDateFormat("EEE-dd-MM-yyyy"); // Set your date format
String currentData = sdf.format(your actual date); // Get Date String according to date format
Here you can see details and all supported format:
http://developer.android.com/reference/java/text/SimpleDateFormat.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With