需要引入的包有:

import java.util.Date;

 

此为获取当前系统时间,合适为“1991-01-01”

  String now = "";
   SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
   now = dateFormat.format(new Date());

 

如果要获取date类型的当前时间,则需要修改为:

SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");

Date now = null;

now = sdf.parse(sdf.format(new Date()));

 

 

相关文章:

  • 2022-01-21
猜你喜欢
  • 2022-01-26
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2021-08-14
  • 2021-12-14
相关资源
相似解决方案