The basic DatePicker at the Android Developers site http://developer.android.com/resources/tutorials/views/hello-datepicker.html appears to display in the format 4-26-2012. Can that formatting be changed to 04-26-2012? It appears to display M-d-yyyy but I need it to display MM-dd-yyyy so 01-01-2012 instead of 1-1-2012. Can the basic DatePicker be tweaked like this?
Asked
Active
Viewed 3,961 times
2
-
Since the default format is the users preferred format, it is recommended to stick to that. The above code will follow the user chosen format. Have a look at the [this link](http://stackoverflow.com/questions/4499433/android-datepicker-widget-format) – Jermin Bazazian Apr 26 '12 at 16:08
2 Answers
1
Hope so you where looking for this only. To override the DatePicker format the best bet would be to override one of its constructors with a slight edit to the original code. You can edit the ViewGroup in code for you but I'd seriously consider not doing it that way.
Refer this Android: How to change the DatePicker view date format from MM/dd/yyyy to dd/MM/yyyy?

Community
- 1
- 1

Shankar Agarwal
- 34,573
- 7
- 66
- 64
1
You know you can extract date, month, year, hour, minute and second and pad it and use it in any format you want. Just create a function. That's how I resolved the date issue when working on .NET web service, SQL Server and android.

drulabs
- 3,071
- 28
- 35
-
Yes, I know you can pad the date many ways. The issue I'm having is I'm querying my DB and have it display a row which is equal to a datepicker date. So currently I have the dates in the DB as yyyyMd so that my Datepicker can see them. I'm also using a SimpleDateFormat to display the date as "Thursday April 26, 2012". The SimpleDateFormat is having trouble with yyyyMd when the months are double digit. Somehow it thinks 20121126 is April 5, 2012, but it's supposed to be November 26, 2012. So I'm trying to figure how to write the dates in the DB and pad them in the code so SDF and DP both work. – kirktoon1882 Apr 26 '12 at 17:51