// 将日期格式转换成时间戳
public static void main(String[] args) throws Exception{
String time = "2018-05-12 12:30:59";
Date parse = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(time);
Long time1 = parse.getTime();
System.out.println(time + " >> " + time1);
// 将时间戳转换成日期格式
public static void main(String[] args) {
Long time = 1527816283000L;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time1 = sdf.format(new Date(time));
System.out.println(time + " >> " + time1);
}