Android Calendar to get current date and time

In applications, we may need the current system date and time. Android developer have a Class named Calendar, let's go see it.


Calendar now = Calendar.getInstance();
  
int year = now.get(Calendar.YEAR)
int month= now.get(Calendar.MONTH);
int day  = now.get(Calendar.DAY_OF_MONTH);

int hour = now.get(Calendar.HOUR);
int min  = now.get(Calendar.MINUTE);
.....

detail please see android developer Calendar

0 意見: