I had a test for object Calendar:
for (int i = 0; i < 11; i++)
System.out.println(calendar.get(i));
output:
1
2011
6
28
2
6
187
4
1
1
10
My question is how can that happen? There are also the same tricky problems for api calendar.get()
I don’t see what the problem is. The documentation states that you get the specific values for whatever field ID you provide.
You would normally use the field constants to get specific values (like
DAY_OF_MONTHorMONTHbut any integer will do provided it’s within the range0..FIELD_COUNT.The field IDs are documented here (though this may change in future) so your specific values are:
That’s
July 6, 2011 AD, somewhere between10:00:00 PMand10:59:59 PMinclusive. The minutes and seconds values are field IDs 12 and 13 and your code doesn’t print them out, hence the uncertainty on the time.