Can anyone help guide me in the right direction? I want to be able to let a button do some time calculations for me.
Basically I want the user to able to press the button and it will take the system time on their device and add numbers to it.
This is the code I have so far:
[HIGH]public void onClickHere (View v) {
Calendar time = Calendar.getInstance();
int hourofday = time.get(Calendar.HOUR_OF_DAY);
int minutes = time.get(Calendar.MINUTE);
time.add(hourofday, 6);
time.add(minutes, 14);
}[/HIGH]
The code above is just an example and it takes the system time and puts it in a TextView. It will also add 6 to the hours and 14 to the minutes. The problem is I get force close errors when the time is something like 1:50pm. You can't add 14minutes to 50minutes. Is there another direction I can take so that it adds up correctly and I can add any number of hours and minutes to any time?
Thanks.
Basically I want the user to able to press the button and it will take the system time on their device and add numbers to it.
This is the code I have so far:
[HIGH]public void onClickHere (View v) {
Calendar time = Calendar.getInstance();
int hourofday = time.get(Calendar.HOUR_OF_DAY);
int minutes = time.get(Calendar.MINUTE);
time.add(hourofday, 6);
time.add(minutes, 14);
}[/HIGH]
The code above is just an example and it takes the system time and puts it in a TextView. It will also add 6 to the hours and 14 to the minutes. The problem is I get force close errors when the time is something like 1:50pm. You can't add 14minutes to 50minutes. Is there another direction I can take so that it adds up correctly and I can add any number of hours and minutes to any time?
Thanks.