/**字符串时间戳转为日期(若为1970时间,说明时间戳不对,时间戳字符串加三个零,或时间戳
long*1000)*/
String time ="1533125387";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(Long.valueOf(time+"000"));
String strTime = sdf.format(date);
System.out.println(strTime);
/**字符串日期转为时间戳*/
String strTime2 ="2018-08-09 14:20:47";
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date date2 = sdf2.parse(strTime2);
String strLong = String.valueOf(date2.getTime()/1000);
System.out.println(strLong);
} catch (ParseException e) {
e.printStackTrace();
}