I am using MaterialDatePicker from material.io. I am able to create date picker and add a function addOnPositiveButtonClickListener, when the date is picked. What I want to do in the function is to get from and to dates picked in datepicker.
But the onPositiveButtonClick has only one argument selection which is an Object, on Logging it using tostring or debugging I can see the selection object is a pair with 2 numbers. Which I assume is timestamp of from and to dates. But I am not able to use the selection pair to get these values seperately.
dateRangePicker.addOnPositiveButtonClickListener(new MaterialPickerOnPositiveButtonClickListener() {
@Override
public void onPositiveButtonClick(Object selection) {
Log.i("selection",selection.toString()); // this prints """ selection "Pair{1655251200000 1657756800000}" """
//selection.getKey() this function does not exist on the pair selection however
}
Can someone help on how to get the from and to dates out of selection(pair/Object) without slicing and dicing the string from toString()