From 6f77987cc4d65033173a70c86d5ecf1e9ad1268e Mon Sep 17 00:00:00 2001 From: ls9487 Date: Fri, 20 Dec 2024 20:52:43 +0800 Subject: [PATCH] Fix bug MaterialTimePicker.java val picker = MaterialTimePicker.Builder() .setTimeFormat(TimeFormat.CLOCK_12H) .setHour(7) .setMinute(0) .setTitleText("Select Time") .build() picker.show(supportFragmentManager, null) picker.hour = 20 (this will set time to 8 am not 8 pm) --- .../google/android/material/timepicker/MaterialTimePicker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/com/google/android/material/timepicker/MaterialTimePicker.java b/lib/java/com/google/android/material/timepicker/MaterialTimePicker.java index 245be3b8763..cb59ccb8c05 100644 --- a/lib/java/com/google/android/material/timepicker/MaterialTimePicker.java +++ b/lib/java/com/google/android/material/timepicker/MaterialTimePicker.java @@ -170,7 +170,7 @@ public int getHour() { /** Sets the hour of day in the range [0, 23]. */ public void setHour(@IntRange(from = 0, to = 23) int hour) { - time.setHour(hour); + time.setHourOfDay(hour); if (activePresenter != null) { activePresenter.invalidate(); }