Can I get milliseconds date value from a datepicker? (the milliseconds since 1970 value)

后端 未结 2 1171
生来不讨喜
生来不讨喜 2021-01-16 21:49

I have a DatePicker d; and I need to get the milliseconds value of the date. (the milliseconds since 1970 value)

how can I do it?

2条回答
  •  庸人自扰
    2021-01-16 22:36

    Create a calender object and set the date and time from the date picker and today.getTimeInMillis().

    onDateSet(...) {
        Calendar c = Calendar.getInstance();
        c.set(...);
        long mills = c.getTimeInMillis();
    }
    

提交回复
热议问题