6

I have defined a xml layout with the DatePicker widget as follows:

     <DatePicker 
        android:id="@+id/SelectDate"
        android:layout_marginTop="10dp"  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:gravity="center|center_horizontal|center_vertical">
    </DatePicker>

and it is being displayed in mm/dd/yyyy format, as below:

alt text

but how can I display the DatePicker widget in (dd/mm/yyyy) format, as below?

alt text

Adinia
  • 3,722
  • 5
  • 40
  • 58
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295

4 Answers4

12

The picker take the date format chosen by the user, which means you don't really have to format it, as probably the user enjoyes the most to see the format he's used to.

I've just tested the HelloDatePicker tutorial and in my phone, I have the date in (dd/mm/yyyy) format, so the picker shows the same format; in emulator, I've put the date in mm/dd/yyyy format, so the picker displays the same.

According to this answer there is no method to set the display format.

Community
  • 1
  • 1
Adinia
  • 3,722
  • 5
  • 40
  • 58
  • ya you are absolutely right, in emulator datepicker is being displayed in mm/dd/yyyy format, whereas the same datepicker widget is being showed in dd/mm/yyyy format. Btw, thanx a lot for quick support – Paresh Mayani Dec 21 '10 at 13:46
  • you are right, but i have one query. When i click on the set button on date picker i got the like 1-6-2011, but i want it like 01-06-11. It is possible? – Datta Kunde Jun 01 '11 at 09:50
  • @Datta I didn't try that, but seems it's not possible with the default one; see this answer: http://stackoverflow.com/questions/4325587/customize-datepicker-android/4325762#4325762 – Adinia Jun 01 '11 at 10:00
1

In android native datepicker will not allow you to change theme and sequence of picker of it at all.

You should try custom date picker component for that because no choice for that.

see this question How do you use custom Datepicker and Timepicker skins? for custom datepicker.You will get answer for custom picker component in that you can customize all the things with theme and sequence of format also.

Community
  • 1
  • 1
Bhavesh Hirpara
  • 22,255
  • 15
  • 63
  • 104
0

If you are working with spanish language (dd/mm/yyyy is how you show the date in spanish), it's all about your local device configuration. DatePicker takes the language format.

Alejandro del Río
  • 3,966
  • 3
  • 33
  • 31
0

Try changing phone settings and choose date format

tbm
  • 1