public SimpleDateFormat(String pattern):使用给定的模式字符串构造一个 SimpleDateFormat 对象
public String format(Date date):将给定的 Date 对象格式化为字符串。
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date now = new Date();
String formattedDate = sdf.format(now);
System.out.println("Formatted date: " + formattedDate);
解析日期
public Date parse(String source) throws ParseException:将给定格式的字符串解析为 Date 对象。
public Object parseObject(String source, ParsePosition pos):将给定格式的字符串解析为对象,从指定位置开始。