Home » Android » android – Get long timestamp from date picker onDateSet

android – Get long timestamp from date picker onDateSet

Posted by: admin June 15, 2020 Leave a comment

Questions:
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
        int dayOfMonth) {

    dateET.setText(dayOfMonth + "/" + monthOfYear + "/" + year);
}

I want to avoid user setting date past to current date.

So, is there a way i can get the long timestamp (may be 12:00 A.M of the date set), so that i can compare it with the current timestamp and if it is less, the date will be set to default(current date + 3 days).

Thank You

How to&Answers:

You have to do it yourself:

Calendar calendar = new GregorianCalendar(year, monthOfYear, dayOfMonth);
calendar.getTimeInMillis();