重点代码: String formatDateStr = simpleDateFormat.format(new Date(time)); Date date = simpleDateFormat.parse(formatDateStr); 详细代码: public static void main(String[] args) throws ParseException { long time = System.currentTimeMillis(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String formatDateStr = simpleDateFormat.format(new Date(time)); Date date = simpleDateFormat.parse(formatDateStr); System.out.println(formatDateStr); System.out.println(date); System.out.println(new Date()); } 运行结果