Can I get milliseconds date value from a datepicker? (the milliseconds since 1970 value)
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?
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();
}
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();
精彩评论