private void hour()
{
Toast.makeText(this,String.valueOf(Calendar.HOUR_OF_DAY),Toast.LENGTH_LONG).show();
}
views:
71answers:
1
+5
A:
Because you just parsed the value of HOUR_OF_DAY which is 11. Forever and ever.
You should create an instance of GregorianCalendar, give it the current date, and use get(Calendar.HOUR_OF_DAY)
Code sample:
Calendar calendar = GregorianCalendar.getInstance();
calendar.setTime(new Date());
int hour = calendar.get(Calendar.HOUR_OF_DAY);
WarrenFaith
2010-08-18 14:15:35
I've made that type of mistake before. Makes for a good slap on the forehead when you find the bug :)
Aaron C
2010-08-18 14:18:40
Thanks a lot WarrenFaith :))
zire
2010-08-18 14:19:53
thats why my wrist is always tied to the table :)
WarrenFaith
2010-08-18 14:20:19