-1

I am aware that the Date includes the time as well. I have date and time picker which is of type `SingleDateAndTimePicker, which I am using from GitHub. I am trying to set the default date. i have tried this code...

poaTime.setDefaultDate();

This requires a Date. However, the problem is that I need to set the default date to today but in the time, I want to set it to 00:01. How can I do that. I am using Java 7 version.

EDIT: This is not a duplicate, because the suggested duplicate is displaying the time in text (string) format instead of in the datetimepicker I have used from GitHub.

Owen
  • 1
  • 2
  • Possible duplicate of [Android: Setting time in time picker with the time shown in text view](https://stackoverflow.com/questions/12494074/android-setting-time-in-time-picker-with-the-time-shown-in-text-view) – Devendra Singh Apr 02 '19 at 10:56

1 Answers1

0

This should work

public Date getDefaultDate() {
   Calendar calendar = Calendar.getInstance();
   calendar.set(Calendar.HOUR, 0);
   calendar.set(Calendar.MINUTE, 1);
   calendar.set(Calendar.SECOND, 0);
   calendar.set(Calendar.MILLISECOND, 0);

   return calendar.getTime();
}

String representation of Date object

Tue Apr 02 00:01:00 UTC 2019
Torsten Ojaperv
  • 1,014
  • 17
  • 24