Ethan Bauer wrote:I'll also ask one more question which is just a thought that popped up while I was writing this source:
Why is it that I have to assign Calendar.getInstance to a variable, in this case "cal", which I then use "get" on with arguments like
Calendar.MINUTE ? Why can't I just do something like:
Why can't I just bundle it, so to speak?
This is nothing important (to progress), but I was just wondering why it is this way..)
If you only wanted to get one value from your Calendar instance you could do that. However, Calendar.getInstance returns a new Calendar instance set to the time at which it was created, so if you used it three times in your code you might get unexpected results.
Assume the time at which you make the first call is 11:59:59, but the time ticks over to 12:00:00 before you make your second and third calls.
With your code as it is
your Calendar instance will represent the time 11:59:59 and it will show the correct time. However, if you used this code
then the time shown will be 11:00:00.
Hours = 11 from the first calendar instance
Minutes = 0 from the second calendar instance
Seconds = 0 from the third calendar instance.