public class DateTime
{
public DateTime()
{
}
/**
* 取年日期时间
* @return String 返回 yyyy-MM-dd HH:mm:ss
*/
public static String getdate() {
SimpleDateFormat formatter_f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date currentTime_f = new Date(); //得到当前系统时间
String new_date_f = formatter_f.format(currentTime_f); //将日期时间格式化
return new_date_f;
}
public static void main(String[] args)
{
DateTime a = new DateTime();
String s = a.getdate();
System.out.println(getdate());
}
}
相关文章:
- Java 格式化日期 2022-12-23
- java 格式化日期 2021-12-30
- java:日期格式化 2022-12-23
- java日期格式化 2022-12-23
- Java日期格式化(DateFormat类和SimpleDateFormat类) 2022-12-23
- Java 日期、时间类,日期、时间的格式化 2021-07-18