florent37 / SingleDateAndTimePicker

You can now select a date and a time with only one widget !
Apache License 2.0
1.02k stars 333 forks source link

Wrong week day #330

Open allenwang-code opened 2 years ago

allenwang-code commented 2 years ago

The weekday of the date is wrong if we look at the image below. Tue 6 Dec should be Mon 6 Dec as we can see the date of tomorrow is showing Wed 8 Dec correctly.

XML:

<com.github.florent37.singledateandtimepicker.SingleDateAndTimePicker
        android:id="@+id/time_picker"
        android:layout_width="0dp"
        android:layout_height="150dp"
        android:layout_marginTop="24dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/time_option_radio_group"
        app:picker_itemSpacing="6dp"
        app:picker_mustBeOnFuture="true"
        app:picker_selectorColor="@android:color/transparent"
        app:picker_stepSizeHours="1"
        app:picker_stepSizeMinutes="15"
        app:picker_visibleItemCount="3" />

Code:

      val calendar = Calendar.getInstance()
      calendar.time = userSelectedDate
      binding.timePicker.maxDate = LocalDateTime().plusWeeks(12).toDate()
      binding.timePicker.selectDate(calendar)

example