content: package com.adevinta.android.barista.sample;
  
  import android.app.DatePickerDialog;
  import android.app.Dialog;
  import android.app.TimePickerDialog;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.DatePicker;
  import android.widget.TextView;
  import android.widget.TimePicker;
  import androidx.annotation.NonNull;
  import androidx.appcompat.app.AppCompatActivity;
  import androidx.fragment.app.DialogFragment;
  import java.util.Calendar;
  
  public class PickersActivity extends AppCompatActivity {
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_pickers);
  
      findViewById(R.id.launch_date_picker).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
          DialogFragment newFragment = new DatePickerFragment();
          newFragment.show(getSupportFragmentManager(), "datePicker");
        }
      });
  
      findViewById(R.id.launch_time_picker).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
          TimePickerFragment fragment = new TimePickerFragment();
          fragment.show(getSupportFragmentManager(), "timePicker");
        }
      });
    }
  
    public static class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
  
      @Override
      public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the current date as the default date in the picker
        final Calendar c = Calendar.getInstance();
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);
  
        // Create a new instance of DatePickerDialog and return it
        return new DatePickerDialog(getActivity(), this, year, month, day);
      }
  
      public void onDateSet(DatePicker view, int year, int month, int day) {
        TextView result = (TextView) getActivity().findViewById(R.id.date_picker_result);
        result.setText(year + "+" + month + "+" + day);
      }
    }
  
    public static class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
  
      @NonNull
      @Override
      public Dialog onCreateDialog(Bundle savedInstanceState) {
        Calendar calendar = Calendar.getInstance();
        final int hour = calendar.get(Calendar.HOUR_OF_DAY);
        final int minute = calendar.get(Calendar.MINUTE);
  
        return new TimePickerDialog(getActivity(), this, hour, minute, true);
      }
  
      @Override
      public void onTimeSet(TimePicker timePicker, int hour, int minute) {
        TextView result = (TextView) getActivity().findViewById(R.id.date_picker_result);
        result.setText(String.format("%d:%d", hour, minute));
      }
    }
  }
  
  