List of usage examples for java.util Date after
public boolean after(Date when)
From source file:org.motechproject.server.service.ANCScheduleTest.java
public void testCreateExpected() { Date date = new Date(); Patient patient = new Patient(1); Capture<Date> minDateCapture = new Capture<Date>(); Capture<Date> dueDateCapture = new Capture<Date>(); Capture<Date> lateDateCapture = new Capture<Date>(); Capture<Date> maxDateCapture = new Capture<Date>(); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.MONTH, -1); Date nextANC1 = calendar.getTime(); calendar.setTime(date);//w w w . j av a2 s . co m calendar.add(Calendar.MONTH, 1); Date nextANC2 = calendar.getTime(); List<Encounter> encounterList = new ArrayList<Encounter>(); Encounter encounter1 = new Encounter(); encounter1.setEncounterDatetime(date); Obs nextANC1Obs = new Obs(); nextANC1Obs.setConcept(nextANCDateConcept); nextANC1Obs.setValueDatetime(nextANC1); encounter1.addObs(nextANC1Obs); encounterList.add(encounter1); Encounter encounter2 = new Encounter(); encounter2.setEncounterDatetime(date); Obs nextANC2Obs = new Obs(); nextANC2Obs.setConcept(nextANCDateConcept); nextANC2Obs.setValueDatetime(nextANC2); encounter2.addObs(nextANC2Obs); encounterList.add(encounter2); List<ExpectedEncounter> expectedEncounterList = new ArrayList<ExpectedEncounter>(); Date pregnancyDate = new Date(); expect(registrarBean.getActivePregnancyDueDate(patient.getPatientId())).andReturn(pregnancyDate); expect(registrarBean.getEncounters(eq(patient), eq(ancSchedule.getEncounterTypeName()), (Date) anyObject())) .andReturn(encounterList); expect(registrarBean.getExpectedEncounters(patient, ancSchedule.getName())) .andReturn(expectedEncounterList); expect(registrarBean.createExpectedEncounter(eq(patient), eq(ancSchedule.getEncounterTypeName()), capture(minDateCapture), capture(dueDateCapture), capture(lateDateCapture), capture(maxDateCapture), eq(ancSchedule.getName()), eq(ancSchedule.getName()))).andReturn(new ExpectedEncounter()); replay(registrarBean); ancSchedule.updateSchedule(patient, date); verify(registrarBean); Date capturedMinDate = minDateCapture.getValue(); assertEquals(encounter2.getEncounterDatetime(), capturedMinDate); Date capturedDueDate = dueDateCapture.getValue(); assertEquals(nextANC2, capturedDueDate); Date capturedLateDate = lateDateCapture.getValue(); assertTrue(capturedLateDate.after(capturedDueDate)); Date capturedMaxDate = maxDateCapture.getValue(); assertTrue(capturedMaxDate.after(capturedDueDate)); }
From source file:org.transdroid.core.service.AppUpdateService.java
@Override protected void onHandleIntent(Intent intent) { // Only run this service if app updates are handled via transdroid.org at all if (!navigationHelper.enableUpdateChecker()) return;//from www. jav a 2s .co m if (!connectivityHelper.shouldPerformBackgroundActions() || !systemSettings.checkForUpdates()) { Log.d(this, "Skip the app update service, as background data is disabled, the service is explicitly " + "disabled or we are not connected."); return; } Date lastChecked = systemSettings.getLastCheckedForAppUpdates(); Calendar lastDay = Calendar.getInstance(); lastDay.add(Calendar.DAY_OF_MONTH, -1); if (lastChecked != null && lastChecked.after(lastDay.getTime())) { Log.d(this, "Skip the update service, as we already checked the last 24 hours (or to be exact at " + lastChecked.toString() + ")."); return; } DefaultHttpClient httpclient = new DefaultHttpClient(); Random random = new Random(); try { // Retrieve what is the latest released app and search module versions String[] app = retrieveLatestVersion(httpclient, LATEST_URL_APP); String[] search = retrieveLatestVersion(httpclient, LATEST_URL_SEARCH); int appVersion = Integer.parseInt(app[0].trim()); int searchVersion = Integer.parseInt(search[0].trim()); // New version of the app? try { PackageInfo appPackage = getPackageManager().getPackageInfo(getPackageName(), 0); Log.d(this, "Local Transdroid is at " + appPackage.versionCode + " and the reported latest version is " + appVersion); if (appPackage.versionCode < appVersion) { // New version available! Notify the user. newNotification(getString(R.string.update_app_newversion), getString(R.string.update_app_newversion), getString(R.string.update_updateto, app[1].trim()), DOWNLOAD_URL_APP + "?" + Integer.toString(random.nextInt()), 90000); } } catch (NameNotFoundException e) { // Not installed... this can never happen since this Service is part of the app itself } // New version of the search module? try { PackageInfo searchPackage = getPackageManager().getPackageInfo("org.transdroid.search", 0); Log.d(this, "Local Transdroid Seach is at " + searchPackage.versionCode + " and the reported latest version is " + searchVersion); if (searchPackage.versionCode < searchVersion) { // New version available! Notify the user. newNotification(getString(R.string.update_search_newversion), getString(R.string.update_search_newversion), getString(R.string.update_updateto, search[1].trim()), DOWNLOAD_URL_SEARCH + "?" + Integer.toString(random.nextInt()), 90001); } } catch (NameNotFoundException e) { // The search module isn't installed yet at all; ignore and wait for the user to manually // install it (when the first search is initiated) } // Save that we successfully checked for app updates (and notified the user) // This prevents checking again for 1 day systemSettings.setLastCheckedForAppUpdates(new Date()); } catch (Exception e) { // Cannot check right now for some reason; log and ignore Log.d(this, "Cannot retrieve latest app or search module version code from the site: " + e.toString()); } }
From source file:com.jidesoft.spring.richclient.docking.JideApplicationLifecycleAdvisor.java
@Override public void onWindowOpened(ApplicationWindow arg0) { super.onWindowOpened(arg0); if (PreferenceRegistry.instance().getPreferenceValue("general.tipOfTheDay").equals("yes")) { GraphicUtils.showTipOfTheDay();//from w w w . j a v a2s.c o m } // automatic version checking // get preference String pval = PreferenceRegistry.instance().getPreferenceValue("updates.autoCheckForNewVersion"); if (pval == null || pval.equals("")) { // if preference is null, ask user if they want to activate version // checking //TODO:I18N final MessageDialog dlg = new MessageDialog("Automatic version check", "As of version 1.0.4 JOverseer comes with a mechanism to automatically check for new versions on the web site.\r\n Note that if you choose yes, JOverseer will try to connect to the internet every time upon start-up to check for a new version.\n Do you wish to activate this check?") { @Override protected Object[] getCommandGroupMembers() { return new Object[] { new ActionCommand("actionYes") { @Override protected void doExecuteCommand() { PreferenceRegistry.instance().setPreferenceValue("updates.autoCheckForNewVersion", "yes"); getDialog().dispose(); } }, new ActionCommand("actionNo") { @Override protected void doExecuteCommand() { PreferenceRegistry.instance().setPreferenceValue("updates.autoCheckForNewVersion", "no"); getDialog().dispose(); } } }; } }; dlg.showDialog(); } // get preference value and do version checking if needed pval = PreferenceRegistry.instance().getPreferenceValue("updates.autoCheckForNewVersion"); if (pval.equals("yes")) { // check once every week Preferences prefs = Preferences.userNodeForPackage(JOverseerJIDEClient.class); pval = prefs.get("lastVersionCheckDate", null); Date dt = null; try { dt = new SimpleDateFormat().parse(pval); } catch (Exception exc) { // do nothing } Calendar c = Calendar.getInstance(); c.setTime(new Date()); c.add(Calendar.DATE, -7); Date dateMinusOneWeek = c.getTime(); if (dt == null || dateMinusOneWeek.after(dt)) { DefaultApplicationDescriptor descriptor = (DefaultApplicationDescriptor) Application.instance() .getApplicationContext().getBean("applicationDescriptor"); ThreepartVersion current = new ThreepartVersion(descriptor.getVersion()); try { if (UpdateChecker .getLatestVersion(PreferenceRegistry.instance().getPreferenceValue("updates.RSSFeed")) .isLaterThan(current)) { new com.middleearthgames.updater.UpdateInfo(UpdateChecker .getWhatsNew(PreferenceRegistry.instance().getPreferenceValue("updates.RSSFeed"))); } String str = new SimpleDateFormat().format(new Date()); prefs.put("lastVersionCheckDate", str); } catch (Exception exc) { // do nothing } } } }
From source file:co.cask.hydrator.plugin.batch.source.XMLReaderBatchSourceTest.java
/** * Method to return currently processed XML file list. *///from w w w .j a v a 2 s .c o m private List<String> getProcessedFileList(String processedFileTable, Date preProcessedDate) throws Exception { List<String> processedFileList = new ArrayList<String>(); DataSetManager<KeyValueTable> dataSetManager = getDataset(processedFileTable); KeyValueTable table = dataSetManager.get(); try (CloseableIterator<KeyValue<byte[], byte[]>> iterator = table.scan(null, null)) { if (iterator != null) { while (iterator.hasNext()) { KeyValue<byte[], byte[]> keyValue = iterator.next(); Date date = new Date(Bytes.toLong(keyValue.getValue())); if (date.after(preProcessedDate)) { processedFileList.add(Bytes.toString(keyValue.getKey())); } } } } return processedFileList; }
From source file:com.discovery.darchrow.date.DateUtil.java
/** * Checks if is after./*from w ww. j a v a2 s .c o m*/ * * @param after * the after * @param when * the when * @return true, if checks if is after * @since 1.2.2 */ public static boolean isAfter(Date after, Date when) { return after.after(when); }
From source file:com.mobileman.moments.core.security.UserSecurityService.java
private void sanitizeUserCacheInfo(UserCacheInfo userCacheInfo) { if (false) {//from ww w. j a v a 2s . c om HashMap<String, Date> tokens = userCacheInfo.getTokens(); if (tokens.size() > 10) { tokens.clear(); // Protection against too many devices } // remove older items Date now = DateUtils.addSeconds(new Date(), -60 * 10); HashSet<String> ks = new HashSet<String>(tokens.keySet()); for (String key : ks) { Date d = tokens.get(key); if (now.after(d)) { tokens.remove(key); } } } }
From source file:net.audumla.climate.bom.BOMPeriodicClimateObserver.java
public boolean supportsDate(Date date) { Date limit = DateUtils.addDays(Time.getDayAndYear(date), -2); // This observer can support observations for 3 days including today. return !(date.before(limit) || date.after(Time.getNow())); }
From source file:de.hybris.platform.accountsummaryaddon.document.dao.impl.DefaultPagedB2BDocumentDaoTest.java
@Test public void shouldReturnDocumentsBetweenDateRange() throws ParseException { final Date minDate = DateUtils.parseDate("2013-08-10", new String[] { "yyyy-MM-dd" }); final Date maxDate = DateUtils.parseDate("2013-08-11", new String[] { "yyyy-MM-dd" }); final DateRange dateRange = new DateRange(minDate, maxDate); final AccountSummaryDocumentQuery query = new B2BDocumentQueryBuilder(0, 10, B2BDocumentModel.OPENAMOUNT, true).addCriteria(B2BDocumentModel.STATUS, DocumentStatus.OPEN) .addCriteria(B2BDocumentModel.DATE, dateRange).build(); final SearchPageData<B2BDocumentModel> result = pagedB2BDocumentDao.findDocuments(query); TestCase.assertEquals(2, result.getResults().size()); Date date0 = result.getResults().get(0).getDate(); Date date1 = result.getResults().get(1).getDate(); date0.after(minDate); TestCase.assertEquals("2013-08-11", sdf.format(date0)); TestCase.assertEquals("2013-08-11", sdf.format(date1)); }
From source file:com.cemeterylistingsweb.services.impl.ViewListingBySubscriberServiceImpl.java
@Override public List<PublishedDeceasedListing> findListingBySubscriber(java.sql.Date subDate, java.sql.Date validDate) { List<PublishedDeceasedListing> publists = publishRepo.findAll(); //find listing by dob List<PublishedDeceasedListing> list = new ArrayList(); for (PublishedDeceasedListing pubListing : publists) { SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); Date parsed = null;/* w ww. j av a2s .c om*/ try { parsed = format.parse(pubListing.getDateOfDeath()); } catch (ParseException ex) { Logger.getLogger(ViewListingBySubscriberServiceImpl.class.getName()).log(Level.SEVERE, null, ex); } java.sql.Date dod = new java.sql.Date(parsed.getTime()); //Date dod = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse(pubListing.getDateOfDeath()); System.out.println(dod); System.out.println(subDate); System.out.println(validDate); if (dod.after(subDate) && dod.before(validDate)) System.out.println(dod); System.out.println("added" + ""); list.add(pubListing); } return list; }
From source file:edu.emory.cci.aiw.i2b2etl.dest.table.ProviderDimensionFactory.java
private Date extract(DateType dateType, String fullNameReference, String firstNameReference, String middleNameReference, String lastNameReference, Proposition encounterProp, Map<UniqueId, Proposition> references) { Date updated = null;/*from w w w . j a v a 2s .c o m*/ if (fullNameReference != null) { updated = extract(dateType, fullNameReference, encounterProp, references); } if (firstNameReference != null) { Date u = extract(dateType, firstNameReference, encounterProp, references); if (u != null) { if (updated == null || u.after(updated)) { updated = u; } } } if (middleNameReference != null) { Date u = extract(dateType, middleNameReference, encounterProp, references); if (u != null) { if (updated == null || u.after(updated)) { updated = u; } } } if (lastNameReference != null) { Date u = extract(dateType, lastNameReference, encounterProp, references); if (u != null) { if (updated == null || u.after(updated)) { updated = u; } } } return updated; }