1
binding.etFirstTime.setOnClickListener{
            val picker = MaterialTimePicker.Builder ()
                .setTimeFormat(TimeFormat.CLOCK_12H)
                . setHour( 12 )
                .setMinute(10)
                .setTitleText("Select Shop's Timing")
                .build()
            picker.showNow(childFragmentManager,"Time")

            picker.addOnPositiveButtonClickListener{
            }
        }
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
  • Welcome to StackOverflow! Please take a look at [how to ask a good question](https://stackoverflow.com/help/how-to-ask) and provide some context to your question beyond just a block of code. – B-Schmidt Mar 18 '21 at 14:12

2 Answers2

1

You don't need to get the time format.
Just use picker.hour. It returns the hour of day in the range [0, 23]

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
0

Try this

 val selectedTime = Calendar.getInstance()
 selectedTime[0, 0, 0, picker.hour, picker.minute] = 0

 val formattedTime = SimpleDateFormat("hh:mm:ss a", Locale.getDefault()).format(selectedTime.time)

Output example: 09:45:00 PM

Tohedul
  • 29
  • 1
  • 7