将日期格式化位指定字符串:

Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String str = sdf.format(date);

将指定格式字符串解析为日期:

String str = "2015-04-17 10:46:43";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = sdf.parse(str);

 

相关文章:

  • 2022-01-19
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-03-08
  • 2021-05-30
  • 2021-09-01
  • 2021-10-15
相关资源
相似解决方案