Android calendar changing time changing date to today
<p>I am using <code>Calendar</code> and I am able to set date and get date for future. Assume that I have one <code>DatePickerDialog</code> which sets date for example <strong>15-09-2016</strong> and I have one <code>TimePickerDialog</code> which sets hour for example : <strong>22:30</strong></p>

<p>My problem is when I use <code>DatePickerDialog</code> and set date to : <strong>15-09-2016</strong> it's ok. But, then I use <code>TimePickerDialog</code> and try to change time, <code>Calendar's</code> date is changing to today (<strong>27-07-2016</strong>).</p>

<p>But if I use <code>TimePickerDialog</code> firstly then use <code>DatePickerDialog</code> there is no issue and I am able to set date : <strong>15-09-2016 22:30</strong></p>

<p>I checked Google and Stackoverflow and looked suggested questions when creating this question but i didnt see anything.</p>

<p>My <code>DatePickerDialog</code> :</p>

<pre><code>DatePickerDialog datePickerDialog=
   new DatePickerDialog(thisActivity, new DatePickerDialog.OnDateSetListener() {
       @Override
       public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
          mCalendarAlarm.set(Calendar.YEAR, year);
          mCalendarAlarm.set(Calendar.MONTH, monthOfYear);
          mCalendarAlarm.set(Calendar.DAY_OF_MONTH, dayOfMonth);
          SimpleDateFormat dateformat = new SimpleDateFormat("dd MMM yyyy kk:mm",Locale.getDefault());
          String datetime = dateformat.format(mCalendarAlarm.getTime());
          alarmDate.setText(datetime);
          }}, mCalendarAlarm.get(Calendar.YEAR), mCalendarAlarm.get(Calendar.MONTH),
          mCalendarAlarm.get(Calendar.DAY_OF_MONTH));

datePickerDialog.getDatePicker().setMinDate(mCalendarAlarm.getTimeInMillis());
datePickerDialog.show();
</code></pre>

<p>My <code>TimePickerDialog</code> :</p>

<pre><code>TimePickerDialog mTimePicker;
int hour = mCalendarAlarm.get(Calendar.HOUR_OF_DAY);
int minute = mCalendarAlarm.get(Calendar.MINUTE); 
mTimePicker = new TimePickerDialog(thisActivity,mPickerTheme, new TimePickerDialog.OnTimeSetListener() {
   @Override
   public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
       mCalendarAlarm.set(Calendar.HOUR_OF_DAY,selectedHour);
       mCalendarAlarm.set(Calendar.MINUTE,selectedMinute);
       alarmDialogTime.setText(String.format(Locale.getDefault(),"%02d:%02d", selectedHour, selectedMinute));
       }}, hour, minute, true);
mTimePicker.show();
</code></pre>

<p>When declaring <code>Calendar</code> :</p>

<pre><code>mCalendarAlarm = Calendar.getInstance();
mCalendarAlarm.setTimeZone(TimeZone.getDefault());
</code></pre>

<p>So how can I solve this issue , is there a way or you guys meet this issue before. Thanks for help !</p>