定時(shí)器和取得類路徑
一、System.getProperty("user.dir");//獲得當(dāng)前項(xiàng)目的類路徑二、定時(shí)器
Timer timer = new Timer();
TimerTask task = new ReportThread();
timer.schedule(task, 1000L, 60*60*1000*12L);//默認(rèn)為12小時(shí)運(yùn)行一次,可根據(jù)實(shí)際情況調(diào)整
在ReportThread中可以通過(guò)this.scheduledExecutionTime()獲得最近一次運(yùn)行的時(shí)間
三、時(shí)間
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.parse(date)
sdf.format(date);
當(dāng)天的前一天
Calendar yestoday = Calendar.getInstance();???????
?yestoday.add(Calendar.DAY_OF_MONTH, -1);
posted on 2010-10-13 10:15 tobyxiong 閱讀(397) 評(píng)論(0) 編輯 收藏 所屬分類: java