kirktoon1882
kirktoon1882

Reputation: 1231

Can Android DatePicker date format be modified?

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?

Upvotes: 2

Views: 3985

Answers (2)

drulabs
drulabs

Reputation: 3121

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.

Upvotes: 1

Shankar Agarwal
Shankar Agarwal

Reputation: 34765

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?

Upvotes: 1

Related Questions