public static void main(String[] args) {
String old_str = "12-12月-2022";
SimpleDateFormat new_format = new SimpleDateFormat("yyyy/MM/dd");
SimpleDateFormat old_format = new SimpleDateFormat("dd-MM月-yyyy");
Date date = null;
try {
date = old_format.parse(old_str);
} catch (ParseException e) {
e.printStackTrace();
}
String new_str = new_format.format(date);
System.out.println(new_str);
}
Java日期的格式转化,从一种格式转化为另一种格式
最新推荐文章于 2024-04-29 15:12:02 发布