我有一个包含 UNIX 时代的字符串,需要将其转换为 JavaDate 对象。
String date = "1081157732";
DateFormat df = new SimpleDateFormat(""); // This line
try {
Date expiry = df.parse(date);
} catch (ParseException ex) {
ex.getStackTrace();
}
标记线是我遇到麻烦的地方。我不知道 SimpleDateFormat ()的参数应该是什么,甚至不知道我是否应该使用 SimpleDateFormat ()。