Android 获取当前时间的方法
2017-03-28 本文已影响155人
赵者也
方法一:
final Calendar c = Calendar.getInstance();
year = c.get(Calendar.YEAR);
month = c.get(Calendar.MONTH);
day = c.get(Calendar.DATE);
hour = c.get(Calendar.HOUR);
minute = c.get(Calendar.MINUTE);
方法二:
long currentTime = System.currentTimeMillis();
String timeNow = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(currentTime);