1.时间转换到时候用到了。
比如需要 显示时间五点半0 5:30,默认是5.30 则需要
String.format("%02d", hour) + ":" + String.format("%02d", minute);
%02d表示显示两位整数 2.根据时间戳获取时间,年月日Date d = new Date(data); Calendar cal = Calendar.getInstance(); SimpleDateFormat formatter_year = new SimpleDateFormat("yyyy");// 设置显示格式 SimpleDateFormat formatter_month = new SimpleDateFormat("MM"); SimpleDateFormat formatter_day = new SimpleDateFormat("dd"); cal.setTimeInMillis(data); int year = cal.get(Calendar.YEAR); int month = now.get(Calendar.MONTH) + 1; int day = now.get(Calendar.DAY_OF_MONTH); int hour = now.get(Calendar.HOUR); int minute = now.get(Calendar.MINUTE);