如何从Android日期选择器中到达日期
我正在使用 materialldatepicker 来自材料。当选择日期时,我可以创建日期选择器并添加一个函数addonPositiveButtonClickListener。我想在功能中做的是从datepicker中获取并选择日期。
但是OnPostiveButtonClick只有一个参数选择
是一个对象,在使用ToString或调试记录时,我可以看到选择
对象是一个具有2个数字的对象。我认为这是时间戳到日期。但是我无法使用选择
对单独获取这些值。
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
}
有人可以帮助如何从选择(配对/对象)中获取从toString()切片和划分字符串的情况下从选择(配对/对象)中获得日期()
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()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以覆盖
onPositiveButtonClick
这样的方法:You can override
onPositiveButtonClick
method like this: