// 获取当前时间
@SuppressLint("SimpleDateFormat")
public static String getNowTime(String format) {
SimpleDateFormat formatter = null;
if (format.equals(""))
formatter = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
else
formatter = new SimpleDateFormat(format);
Date curDate = new Date(System.currentTimeMillis());// 获取当前时间
String str = formatter.format(curDate);
return str;
}
// 将时间戳转换成时间显示
@SuppressLint("SimpleDateFormat")
public static String convertToTime(int mill, String format) {
SimpleDateFormat sdf = null;
if (format.equals(""))
sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
else
sdf = new SimpleDateFormat(format);
String date = sdf.format(new Date(mill * 1000L));
return date;
}