title: After picking date and time from Date & Time Picker, how to pass them as parameters in 'Create Event' function of Calendars?
body: <p>I have a Date &amp; Time Picker widget of Android Studio, from which i have selected a particular date(dd-mm-yy) format and time(hr:min) format.</p>
  
  <p>Now, in the same <code>Activity</code> i have a 'Submit' button;by clicking on it, i pass several parameters to the 'Create Event' of my phone's native Calendar.</p>
  
  <p>While i can successfully pass the title,description, location etc. i don't know how to pass the 'Start-End Date' &amp; 'Start-End' Time parameters that i have chosen from the Date &amp; Time Picker to the Native Calendar.</p>
  
  <p>Thanks.</p>
  
  <p>Here, is a brief code of the same:</p>
  
  <p>1> Selecting date function: </p>
  
  <pre><code>private void selectDate()
  {
      final Calendar c = Calendar.getInstance();
      mYear = c.get(Calendar.YEAR);
      mMonth = c.get(Calendar.MONTH);
      mDay = c.get(Calendar.DAY_OF_MONTH);
  
      DatePickerDialog dpd = new DatePickerDialog(getActivity(),
              new DatePickerDialog.OnDateSetListener()
              {
  
                  @Override
                  public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)
                  {
                      Toast.makeText(getActivity(), dayOfMonth + "-" + (monthOfYear + 1) + "-" + year, Toast.LENGTH_LONG).show();
                  }
              }, mYear, mMonth, mDay);
      dpd.show();
  }
  </code></pre>
  
  <p>2> Selecting Time function:</p>
  
  <pre><code>private void selectTime()
  {
      final Calendar c = Calendar.getInstance();
      mHour = c.get(Calendar.HOUR_OF_DAY);
      mMinute = c.get(Calendar.MINUTE);
  
      TimePickerDialog tpd = new TimePickerDialog(getActivity(),
              new TimePickerDialog.OnTimeSetListener()
              {
  
                  @Override
                  public void onTimeSet(TimePicker view, int hourOfDay, int minute)
                  {
                      Toast.makeText(getActivity(), hourOfDay + ":" + minute, Toast.LENGTH_LONG).show();
                  }
              }, mHour, mMinute, false);
      tpd.show();
  }      
  </code></pre>
  
  <p>3) On Submit button click:</p>
  
  <pre><code>Sb.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
          Intent schedule = new Intent(Intent.ACTION_INSERT);
          schedule.setType("vnd.android.cursor.item/event");
          schedule.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,   startTime);
          schedule.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime);
          schedule.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, false);
          schedule.putExtra(CalendarContract.Events.TITLE, "Title");
          schedule.putExtra(CalendarContract.Events.EVENT_LOCATION, "Location");
          startActivity(schedule);
          }
      });
  </code></pre>
  
  <p><strong>I have edited my code to accommodate a suggestion:</strong>  </p>
  
  <pre><code>private void selectTime()
  {
      TimePickerDialog tpd = new TimePickerDialog(getActivity(),
              new TimePickerDialog.OnTimeSetListener()
              {
  
                  @Override
                  public void onTimeSet(TimePicker view, int hourOfDay, int minute)
                  {
                       c.set(Calendar.HOUR_OF_DAY, hourOfDay);
                       c.set(Calendar.MINUTE, minute);
  
                      Toast.makeText(getActivity(), hourOfDay + ":" + minute, Toast.LENGTH_LONG).show();
                  }
              }, mHour, mMinute, false);
      tpd.show();
  }
  
   private void selectDate()
  {
      DatePickerDialog dpd = new DatePickerDialog(getActivity(),
              new DatePickerDialog.OnDateSetListener()
              {
  
                  @Override
                  public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)
                  {
                      c.set(year, monthOfYear, dayOfMonth);
  
                      Toast.makeText(getActivity(), dayOfMonth + "-" + (monthOfYear + 1) + "-" + year, Toast.LENGTH_LONG).show();
                  }
              }, mYear, mMonth, mDay);
      dpd.show();
  }
  </code></pre>
  
  <p><strong>Now, the time &amp; date both perfectly changes/updates every time i create a new event!Thanks</strong></p>