Add a spinner for date formats
<de.j4velin.dateFormatSpinner.DateFormatSpinner
xmlns:spinner="http://schemas.android.com/apk/res-auto"
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
spinner:defaultFormats="date"/>
or for time formats
<de.j4velin.dateFormatSpinner.DateFormatSpinner
xmlns:spinner="http://schemas.android.com/apk/res-auto"
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
spinner:defaultFormats="time"/>
to your layout xml file. To use the selected format in your code, call the getValue() method on the Spinner:
String pattern = ((DateFormatSpinner) getView().findViewById(R.id.date)).getValue();
String formatedDate = new SimpleDateFormat(pattern).format(System.currentTimeMillis());