public static void main(String[] args) throws ParseException {
// 时间格式化
long time3 = System.currentTimeMillis();//获取系统时间
SimpleDateFormat format1 = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
System.out.println(format1.format(time3));
//时间反格式化
String time="2016年09月10日 01:33:55";
SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
long lTime2 = 0;
lTime2 = format.parse(time).getTime();
System.out.println(lTime2);
}
反格式化时有一个异常处理,需要抛出异常,也可以自己处理,系统默认的时间是一个long类型的