Java 获取当前系统时间 格式:yyyy-MM-dd HH:mm:ss

 

//获取当前时间类,并储存为特定的函数

import java.util.Date;
import java.text.SimpleDateFormat;

public class GetCorrentTime {
   public static  SimpleDateFormat  GetTime() {     
   SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
 
      return df;// new Date()为获取当前系统时间
   }
}

 

//调用前面的那个类

SimpleDateFormat Time=GetCorrentTime.GetTime(); //返回一个SimpleDateFormat类的对象

Time.format( new java.util.Date()) // new date() 获取系统时间,并转化为特定格式

posted @ 2010-03-31 19:36  樱色布  阅读(12569)  评论(0编辑  收藏  举报