Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import android.widget.DatePicker; public class Main { public static long getDate(int year, int monthOfYear, int dayOfMonth) { Calendar c = Calendar.getInstance(); c.set(year, monthOfYear, dayOfMonth); return c.getTimeInMillis(); } /** * @param datePicker * @return date with the hours/minutes/seconds/milliseconds stripped off */ public static long getDate(DatePicker datePicker) { return getDate(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth()); } public static int getYear(long date) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(date); return c.get(Calendar.YEAR); } public static int getDayOfMonth(long date) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(date); return c.get(Calendar.DAY_OF_MONTH); } }