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());
}
}
posted @ 2011-04-15 11:44  Atypiape2  阅读(194)  评论(0编辑  收藏  举报