Wednesday, 27 March 2019

Date format changing on RTL devices?

I have a date field that is presented great on LTR devices (android 7.1.1)
The issue is that on RTL devices the date field content is mirrored

So on US devices the date will appear normally : 03/14/2019
On RTL android devices the date will appear like so: 2019/14/03

Code for the TextView holding the value:

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/inspect_date"
            android:textSize="18sp" />

        <com.xerox.printerinspection.controls.DateEditText
            android:id="@+id/edit_inspect_date"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:background="@color/lightGray"
            android:paddingStart="4dp"
            android:paddingEnd="4dp"
            android:drawableEnd="@android:drawable/ic_menu_my_calendar" />
    </LinearLayout>

I am setting the date like so:

   Date currentDate = Calendar.getInstance().getTime();
   inspectionDateEdit.setDate(currentDate);

What will be the correct way to fix this issue?



from Date format changing on RTL devices?

No comments:

Post a Comment