'subtract two timePickerDialog
I have two buttons that open two timePickerDialogs, one is the start time and the other is the end time. How can I extract the difference in hours and minutes between timePickerDialogIni and timePickerDialogFin?
in declarations
var mHourIni: Int = 0
var mMinuteIni: Int = 0
var mHourFin: Int = 0
var mMinuteFin: Int = 0
in metod onCkick
R.id.btn_timeIni ->{
mHourIni = calendar.get(Calendar.HOUR)
mMinuteIni = calendar.get(Calendar.MINUTE)
val timePickerDialogIni = TimePickerDialog(this,
{ view, hourOfDay, minute -> btnTimeIni!!.setText( hourOfDay.toString() + ":" + String.format("%02d", minute))},
mHourIni!!, mMinuteIni!!, true)//
timePickerDialogIni.show()
}
R.id.btn_timeFin ->{
mHourFin = calendar.get(Calendar.HOUR)
mMinuteFin = calendar.get(Calendar.MINUTE)
val timePickerDialogFin = TimePickerDialog(this,
{ view, hourOfDayFin, minuteFin -> btnTimeFin!!.setText ( hourOfDayFin.toString() + String.format("%02d", minuteFin) +"" )},
mHourFin!!, mMinuteFin!!, true)
timePickerDialogFin.show()
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
