get Date From Date Picker - Android android.widget

Android examples for android.widget:DatePicker

Description

get Date From Date Picker

Demo Code

import android.widget.DatePicker;
import java.util.Calendar;
import java.util.Date;

public class Main{

    /**/*w  ww .  j  a va  2s . c  o  m*/
     * Gets the date from date picker.
     *
     * @param datePicker the date picker
     * @return the date from date picket
     */
    public static Date getDateFromDatePicker(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();
    }

}

Related Tutorials