1. Forward Change
New_time=text1.gettext ();//The time taken from the text box
New_date=formatter_2.parse (new_time);//Convert the time in a text box to a date type
Cal.settime (new_date);
New_time_1=text2.gettext ();//The time taken from the text box
New_date_1=formatter_2.parse (new_time_1);//Convert the time in a text box to a date type
Cal_1.settime (new_date_1);
Long Diff=new_date_1.gettime ()-new_date.gettime ();//Get time difference
Long days=diff/(1000*60*60*24);//difference in number of days
Long hours= (diff-days* (1000*60*60*24))/(1000*60*60);//Hours of difference
Long minutes= (diff-days* (1000*60*60*24)-hours* (1000*60*60))/(1000*60);//number of minutes of difference
cal.add (calendar.day_of_month, (int)-days);
cal.add (calendar.hour, (int)-hours);
cal.add (Calendar.minute, (int)-minutes);
new_date=cal.gettime ();
string Test_time=formatter_2.format (new_date);
stringbuffer test_str=new StringBuffer (). append (Test_time);
test_time=test_str.tostring ();
text1.settext (test_time);
string first_time=text1.gettext ();
cal_1.add (Calendar.day_of_month, (int)-days);
cal_1.add (Calendar.hour, (int)-hours);
cal_1.add (Calendar.minute, (int)-minutes);
new_date_1=cal_1.gettime ();
string Test_time_1=formatter_2.format (new_date_1);
stringbuffer test_str_1=new StringBuffer (). append (Test_time_1);
test_time_1=test_str_1.tostring ();
text2.settext (test_time_1);
string last_time_1=text2.gettext ();
2. Backward change
New_time=text1.gettext ();//The time taken from the text box
New_date=formatter_2.parse (new_time);//Convert the time in a text box to a date type
Cal.settime (new_date);
New_time_1=text2.gettext ();//The time taken from the text box
New_date_1=formatter_2.parse (new_time_1);//Convert the time in a text box to a date type
Cal_1.settime (new_date_1);
Long Diff=new_date_1.gettime ()-new_date.gettime ();//Get time difference
Long days=diff/(1000*60*60*24);//difference in number of days
Long hours= (diff-days* (1000*60*60*24))/(1000*60*60);//Hours of difference
Long minutes= (diff-days* (1000*60*60*24)-hours* (1000*60*60))/(1000*60);//number of minutes of difference
Cal.add (Calendar.day_of_month, (int) +days);
Cal.add (Calendar.hour, (int) +hours);
Cal.add (Calendar.minute, (int) +minutes);
new_date=cal.gettime ();
string Test_time=formatter_2.format (new_date);
stringbuffer test_str=new StringBuffer (). append (Test_time);
test_time=test_str.tostring ();
text1.settext (test_time);
string first_time=text1.gettext ();
cal_1.add (Calendar.day_of_month, (int) +days);
cal_1.add (Calendar.hour, (int) +hours);
cal_1.add (Calendar.minute, (int) +minutes);
new_date_1=cal_1.gettime ();
string Test_time_1=formatter_2.format (new_date_1);
stringbuffer test_str_1=new StringBuffer (). append (Test_time_1);
test_time_1=test_str_1.tostring ();
text2.settext (test_time_1);
string last_time_1=text2.gettext ();
java--Sets the time difference in a text box to change in units