@Override public void contextInitialized(ServletContextEvent arg0) { // TODO Auto-generated method stub timer = new Timer(); timeSimple = new TimeSimple();
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String now = sf.format(new Date()); String result = now.substring(0,11)+time; System.out.println(now+"~~~~~~~~~~~~~~~~~~~"+result); System.out.println(now.substring(13)); try { long target = sf.parse(result).getTime()-new Date().getTime(); System.out.print("the method will be start after "+target); timer.schedule(timeSimple, target<0?target+24*60*60*1000:target, 24*60*60*1000); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); }
日誌信息:
2012-04-18 10:00:00,102 DEBUG PreparedStatement:23 - {pstm-103295} PreparedStatement: insert into HisSummary select sycom, TableNumber, TableAreaType, GameDay, OccurenceTime, WinLossAmount, Status, RegDate, CurrFlag, Turnover from CurrTabSumry WHERE GameDay<>(select max(GameDay) GameDay from CurrTabSumry (nolock) ) 2012-04-18 10:00:00,118 DEBUG PreparedStatement:23 - {pstm-103295} Parameters: [] 2012-04-18 10:00:00,118 DEBUG PreparedStatement:23 - {pstm-103295} Types: [] 2012-04-18 10:00:05~~~~~~~~~~~~~~~~~~~2012-04-18 10:00:00 :00:05 the method will be start after -59622012-04-18 10:00:06,368 INFO CheckSessionOutFilter:53 - /js/LoadSummary.jsp 2012-04-18 10:00:06,368 INFO CheckSessionOutFilter:54 - loginName=05897;gameday=2012-04-18; sqlMapClient initing..... 2012-04-18 10:00:07,196 DEBUG Connection:23 - {conn-100000} Connection 2012-04-18 10:00:07,259 DEBUG PreparedStatement:23 - {pstm-100001} PreparedStatement: select ID,sycom,companyname ,description,propertyVal from property order by sycom 2012-04-18 10:00:07,259 DEBUG PreparedStatement:23 - {pstm-100001} Parameters: [] 2012-04-18 10:00:07,274 DEBUG PreparedStatement:23 - {pstm-100001} Types: [] 2012-04-18 10:00:07,290 DEBUG ResultSet:23 - {rset-100002} ResultSet