java如何给时间格式化

java中如何格式化的时间,这是一个很简单的问题,在实际的.编程中经常用,以下是小编为大家搜索整理的java如何给时间格式化,希望能给大家带来帮助!更多精彩内容请持续关注我们应届毕业生考试网!

java如何给时间格式化

日期格式化

import ;

import leDateFormat;

class dayTime

{

public static void main(String args[])

{

Date nowTime=new Date();

tln(nowTime);

SimpleDateFormat time=new SimpleDateFormat("yyyy MM dd HH mm ss");

tln(at(nowTime));

}

}

public void timerStop(){

if(timer!=null)

el();

}

public static void main(String[] args){

BugXmlTimer myTimer=new BugXmlTimer();

// TODO Auto-generated method stub

rStart();

}

}

//这是执行任务的类,即每隔一段时间要做的事情在这里

package ;

import rTask;

public class BugXmlTimerTask extends TimerTask {

@Override

public void run() {

t("run task");

}

}

//以下是出发定时操作的类,该类实现了ServletContextListener

public class MyTimerListener implements ServletContextListener {

private BugXmlTimer mytimer = new BugXmlTimer ();

public void contextInitialized(ServletContextEvent event) {

rStart();

}

public void contextDestroyed(ServletContextEvent event) {

rStop();

}

}

然后在里部署一下,即可在程序启动后运行定时器了!

merListener