I would like to to substract hour that is displayed in textview1
from hour that is displayed in textview2
. Im setting the hour in textview
by pressing buttons
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String sdf = new SimpleDateFormat("HH:mm", Locale.US).format(new Date());
textView.setText(sdf);
button1.setVisibility(View.GONE);
button2.setVisibility(View.VISIBLE);
}
});
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String sdf = new SimpleDateFormat("HH:mm", Locale.US).format(new Date());
textView2.setText(sdf);
button1.setVisibility(View.VISIBLE);
button2.setVisibility(View.GONE);
now after clicking button2
i also want to substract hours and set result of substraction in textview3
. I tried to get TextViews value and put it to strings, but i guess that's not the correct way to do this. If you guys could show me how to do this, please.