我想在我的JSP页面上每秒钟打印当前日期和时间,TimerTask类的run()仅返回void。我如何从此类返回当前时间,请任何Java Geeks帮助我解决这个问题>
public class ITCBillDeskRetrieveTrialDDHHMMSS extends TimerTask
{
Logger
logger=Logger.getLogger(ITCBillDeskRetrieveTrialDDHHMMSS.class);
public static String retrieveTraialDate;
@Override
public void run()
{
try
{
retrieveTraialDate();
}
catch (ParseException | IOException e)
{
e.printStackTrace();
}
}
//print Current & Print Date //
public Date retrieveTraialDate() throws ParseException, IOException
{
Date currentDate=new Date();
System.out.println("Current Date $$$ "+currentDate);
return currentDate;
}
public static void main(String args[]) throws ParseException,
IOException
{
Timer timer=new Timer ();
timer.schedule(new ITCBillDeskRetrieveTrialDDHHMMSS(),0,1000);
}
}