SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
String s = df.format(currentTimeMillis);//时间戳 转String(2018-02-10 12:03:41)
Date date = new Date();//获取系统当前时间 Sat Feb 10 13:40:03 CST 2018
long time = date.getTime();//date 转时间戳(long 1518235421189)
long currentTimeMillis = System.currentTimeMillis();//获取当前时间戳 1518235421189String s = df.format(currentTimeMillis);//时间戳 转String(2018-02-10 12:03:41)
Date parse = df.parse(s);//String 转date(Sat Feb 10 12:03:41 CST 2018)
Calendar now = Calendar.getInstance();
now.set(Calendar.DATE, now.get(Calendar.DATE)-5);//获取五天前
now.getTimeInMillis()//Calendar 转时间戳