Android DatePicker Get getDateFromDatePicket(DatePicker datePicker)

Here you can find the source of getDateFromDatePicket(DatePicker datePicker)

Description

Get the date as milliseconds from a DatePicker

Parameter

Parameter Description
datePicker a parameter

Declaration

public static java.util.Date getDateFromDatePicket(DatePicker datePicker) 

Method Source Code

//package com.java2s;
import java.util.Calendar;
import android.widget.DatePicker;

public class Main {
    /**//from  w  w w.j a va  2s .com
     * Get the date as milliseconds from a DatePicker
     * 
     * @param datePicker
     * @return
     */
    public static java.util.Date getDateFromDatePicket(DatePicker datePicker) {
        int day = datePicker.getDayOfMonth();
        int month = datePicker.getMonth();
        int year = datePicker.getYear();

        Calendar calendar = Calendar.getInstance();
        calendar.set(year, month, day);

        return calendar.getTime();
    }
}