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

后端 未结 2 1146
生来不讨喜
生来不讨喜 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:47

    You just have to convert your result, using Calendar, or, more easily, Joda-Time

    Here is an example with Joda-Time :

    DateMidnight d = new DateMidnight(picker.getYear(), picker.getMonth(), picker.getDayOfMonth());
    long millis = d.toDate().getTime();
    

提交回复
热议问题