Java格式化日期类
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());
}
}