1. 程式人生 > >Android獲得當前日期和時間的方法

Android獲得當前日期和時間的方法

Calendar c = Calendar.getInstance();
year  = c.get(Calendar.YEAR);
month = c.get(Calendar.MONTH);
day   = c.get(Calendar.DAY_OF_MONTH);
hour  = c.get(Calendar.HOUR_OF_DAY);
minute = c.get(Calendar.MINUTE);
second = c.get(Calendar.SECOND);
week = c.get(Calendar.DAY_OF_WEEK);