List of usage examples for java.util Timer Timer
public Timer()
From source file:svc.managers.DemoManager.java
public List<DemoCitation> createCitationsAndViolations() { List<DemoCitation> demoCitations = new ArrayList<DemoCitation>(); DemoUtilities demoUtilities = new DemoUtilities(); List<Citation> citations = demoUtilities.generateRandomCitations(); List<Violation> violations = demoUtilities.generateRandomViolations(); mockCitationDataSource.insertCitations(citations); violationManager.insertViolations(violations); for (int citationCount = 0; citationCount < citations.size(); citationCount++) { Citation citation = citations.get(citationCount); int numberOfViolations = 0; for (int violationCount = 0; violationCount < violations.size(); violationCount++) { if (violations.get(violationCount).citation_number.equals(citation.citation_number)) { numberOfViolations++;/*from w w w. j a v a 2 s . co m*/ } } DemoCitation demoCitation = new DemoCitation(); demoCitation.citationNumber = citation.citation_number; demoCitation.dob = citation.date_of_birth; demoCitation.driversLicenseNumber = citation.drivers_license_number; Period daysTillCourt = DatabaseUtilities.getCurrentDate().until(citation.court_dateTime.toLocalDate()); demoCitation.daysTillCourt = daysTillCourt.getDays(); demoCitation.numberOfViolations = numberOfViolations; demoCitations.add(demoCitation); } Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { mockCitationDataSource.removeCitations(citations); violationManager.removeViolations(violations); } }, 60 * 60 * 1000); return demoCitations; }
From source file:com.shanet.relayremote.Background.java
public Background(Context context, final char op, boolean isWidget) { this.context = context; this.op = op; this.isWidget = isWidget; // If a widget, don't show any dialogs if (isWidget) return;// ww w. ja v a 2 s . com dialog = new ProgressDialog(context); // Show a dialog if the bg thread runs longer than the time specified in onPreExecute() below timer = new Timer(); tt = new TimerTask() { @Override public void run() { Looper.prepare(); ((Activity) Background.this.context).runOnUiThread(new Runnable() { public void run() { dialog = ProgressDialog.show(Background.this.context, "", Background.this.context.getString( (op == Constants.OP_SET) ? R.string.connServer : R.string.gettingStates)); } }); } }; }
From source file:com.cnaude.purpleirc.Utilities.UpdateChecker.java
public void asyncUpdateCheck(final CommandSender sender, final String mode) { Timer t = new Timer(); t.schedule(new TimerTask() { @Override//from w w w .jav a 2 s .c om public void run() { if (plugin.isUpdateCheckerEnabled()) { updateCheck(sender, mode); } } }, 0); }
From source file:org.starfishrespect.myconsumption.server.business.Watcher.java
/** * Starts scheduling data retrieving//from www. j av a 2 s . c o m */ @Override public void run(String... args) throws Exception { retriever = new SensorsDataRetriever(mSensorRepository, mValuesRepository); statUpdater = new StatisticsUpdater(mSensorRepository, mPeriodStatRepository, mDayStatRepository); notifier = new Notifier(mApiKey, mSensorRepository, mPeriodStatRepository, mUserRepository); nextRetrieve = System.currentTimeMillis() + maxRetrieveInterval; Timer retrieveTimer = new Timer(); retrieveTimer.schedule(new WatcherTask(), 0); Timer notificationSender = new Timer(); notificationSender.schedule(new NotificationTask(), 0); }
From source file:gov.nih.nci.caxchange.messaging.AdverseEventLoadTest.java
/** * Testcase for sending the messages/*www. j a va2 s . c om*/ * * @throws InterruptedException - InterruptedException */ @Test public void sendAdverseEventMessage() throws InterruptedException { final Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(currDt.getTime() + 5000); currDt = calendar.getTime(); final Timer timer = new Timer(); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); timer.schedule(getTimerTask(), currDt); es.awaitTermination(3, TimeUnit.MINUTES); }
From source file:com.symbian.driver.remoting.client.SubmissionMonitor.java
/** * Start a timer/*from w w w . ja va 2s . co m*/ * */ public void start() { timer = new Timer(); timer.schedule(new SubmissionCheckTask(), seconds * DELAY_TIME, seconds * DELAY_TIME); }
From source file:com.spend.spendService.SearchText.java
private void Search() { try {//from ww w. j a v a 2 s . c om TimerTask timertask = new TimerTask() { public void run() { try { String[] seList = getSearchEngineNamesArray(); /* get search queries from keywords table */ PreparedStatement psmt = con.prepareStatement("SELECT searchKeyword FROM keywords"); ResultSet rs = psmt.executeQuery(); while (rs.next()) { searchQuery = rs.getString("searchKeyword"); /* insert search queries into searchqueue table */ for (Object se : seList) { PreparedStatement psmt1 = con.prepareStatement( "INSERT INTO searchqueue(searchText,disabled,searchEngineName) VALUES(?,0,?);"); psmt1.setString(1, searchQuery); psmt1.setString(2, se.toString()); psmt1.executeUpdate(); psmt1.close(); } } } catch (Exception ex) { System.out.println("SearchText.java timertask run function SQL ERROR " + ex.getMessage()); } } }; Timer timer = new Timer(); DateFormat dateformat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); Date date = dateformat.parse("20-07-2017 00:00:00"); // set time and date timer.schedule(timertask, date, 1000 * 60 * 60 * 24); // for 24 hour 1000*60*60*24 } catch (Exception ex) { System.out.println("SearchText.java Search function ERROR " + ex.getMessage()); } }
From source file:AlarmMIDlet.java
public void commandAction(Command c, Displayable s) { if (c == alarmCommand) { if (dateOK == false) { Alert aAlert = new Alert("Cannot set", "Warning", null, null); aAlert.setTimeout(Alert.FOREVER); aAlert.setType(AlertType.ERROR); display.setCurrent(aAlert);/*from w w w . j ava 2 s . c o m*/ } else { aTimer = new Timer(); alarmTimerTask aTimerTask = new alarmTimerTask(); long amount = alarmTimeSetting.getDate().getTime() - currentTime.getTime(); aTimer.schedule(aTimerTask, amount); aForm.removeCommand(alarmCommand); aForm.removeCommand(resetCommand); aForm.delete(dateIndex); aForm.setTitle("Waiting...."); } } else if (c == resetCommand) { alarmTimeSetting.setDate(currentTime = new Date()); } else if (c == exitCommand) { destroyApp(false); notifyDestroyed(); } }
From source file:com.anritsu.mcrepositorymanager.utils.Packing.java
public Packing(ArrayList<McPackage> packageListToBePacked) { this.packageListToBePacked = packageListToBePacked; archiveNameFile = new File(REPOSITORY_LOCATION + ARCHIVE_NAME); try {/* ww w. j a va2 s. co m*/ out = new ZipOutputStream(new FileOutputStream(archiveNameFile)); } catch (FileNotFoundException ex) { Logger.getLogger(Packing.class.getName()).log(Level.SEVERE, null, ex); } for (McPackage p : packageListToBePacked) { p.setPackageSize(getPackageSize(p)); } // Update status.packageDownloadedSize Timer t = new Timer(); t.schedule(new TimerTask() { @Override public void run() { try { String fileName = status.getProcessingPackage().getFileName(); File f = new File(FOLDER_PATH + fileName); status.getProcessingPackage().setPackageDownloadedSize(f.length()); } catch (Exception exp) { status.getProcessingPackage().setPackageDownloadedSize(0); } } }, 0, 1000); }
From source file:com.github.hailinzeng.filemonitor.FileMonitor.java
/** * begin timer */ public void start() { timer = new Timer(); timer.schedule(new CheckTask(), 1000, interval); }