List of usage examples for java.util Date after
public boolean after(Date when)
From source file:gov.nih.nci.firebird.test.nes.NesTestDataLoader.java
boolean isCachedDataFresh() { Date lastModified = new Date(getCacheFile().lastModified()); return lastModified.after(DateUtils.addDays(new Date(), -1)); }
From source file:com.example.android.rowanparkingpass.Activities.PassActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pass); i = 0;/* www . java 2s. c om*/ Intent pastIntent = getIntent(); currentMode = pastIntent.getStringExtra(MODE); db = new DatabaseHandlerPasses(getApplicationContext()); Pass pass = (Pass) pastIntent.getSerializableExtra("Pass"); if (pass == null) { driver = (Driver) pastIntent.getSerializableExtra("Driver"); vehicle = (Vehicle) pastIntent.getSerializableExtra("Vehicle"); } else { driver = pass.getDriver(); vehicle = pass.getVehicle(); } setDriverView(); setVehicleView(); dateFormatter = new SimpleDateFormat("MM/dd/yyyy"); startDate = (EditText) findViewById(R.id.createstartdatefield); startDate.setInputType(InputType.TYPE_NULL); startDate.setOnClickListener(this); endDate = (EditText) findViewById(R.id.createenddatefield); endDate.setInputType(InputType.TYPE_NULL); endDate.setOnClickListener(this); Calendar calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); int day = calendar.get(Calendar.DAY_OF_MONTH); calendar.set(year, month, day); startDate.setText(dateFormatter.format(calendar.getTime())); calendar.add(Calendar.DAY_OF_MONTH, 1); endDate.setText(dateFormatter.format(calendar.getTime())); startDatePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Calendar newDate = Calendar.getInstance(); newDate.set(year, monthOfYear, dayOfMonth); startDate.setText(dateFormatter.format(newDate.getTime())); try { Date d = newDate.getTime(); Date d2 = dateFormatter.parse(endDate.getText().toString()); if (d.after(d2)) { newDate.add(Calendar.DAY_OF_MONTH, 1); endDate.setText(dateFormatter.format(newDate.getTime())); } } catch (ParseException pe) { pe.printStackTrace(); } } }, year, month, day); endDatePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker datePicker, int year, int monthOfYear, int dayOfMonth) { Calendar newDate = Calendar.getInstance(); newDate.set(year, monthOfYear, dayOfMonth); endDate.setText(dateFormatter.format(newDate.getTime())); try { Date d = newDate.getTime(); Date d2 = dateFormatter.parse(startDate.getText().toString()); if (d.before(d2)) { newDate.add(Calendar.DAY_OF_MONTH, -1); startDate.setText(dateFormatter.format(newDate.getTime())); } } catch (ParseException pe) { pe.printStackTrace(); } } }, year, month, day); createPass = (Button) findViewById(R.id.createPassButton); mainMenu = (Button) findViewById(R.id.goMainMenuButton); createPass.setOnClickListener(this); mainMenu.setOnClickListener(this); }
From source file:it.drwolf.ridire.session.async.JobDBDataUpdater.java
private String getJobStatus(String encodedJobName) throws HttpException, IOException, DocumentException { // back compatibility Heritrix 2 if (encodedJobName.startsWith("completed-")) { return CrawlStatus.FINISHED.toString(); }/*ww w . j a v a 2 s . c o m*/ File jobDir = new File(this.jobsDir + CrawlerManager.FILE_SEPARATOR + encodedJobName); String[] files = jobDir.list(); if (files == null || files.length < 2) { return CrawlStatus.CREATED.toString(); } String ret = CrawlStatus.CREATED.toString(); RandomAccessFile progressStatistics = null; Calendar now = new GregorianCalendar(); Date comparingDate = DateUtils.addDays(now.getTime(), -3); try { progressStatistics = new RandomAccessFile( this.jobsDir + CrawlerManager.FILE_SEPARATOR + encodedJobName + CrawlerManager.FILE_SEPARATOR + "logs" + CrawlerManager.FILE_SEPARATOR + "progress-statistics.log", "r"); if (progressStatistics != null) { progressStatistics.seek(Math.max(0, progressStatistics.length() - 3000)); String line = progressStatistics.readLine(); StringBuffer buffer = new StringBuffer(); while (line != null) { buffer.append(line + "\n"); line = progressStatistics.readLine(); } String progressStatisticsContent = buffer.toString(); Matcher m = this.progressStatisticsDatePattern.matcher(progressStatisticsContent); int start = 0; String lastDateString = ""; while (m.find(start)) { start = m.end(); lastDateString = m.group(); } Date lastDate = this.progressStatisticsDateFormat.parse(lastDateString); if (!progressStatisticsContent.contains("CRAWL ENDED - Finished") && lastDate.after(comparingDate)) { ret = CrawlStatus.RUNNING.toString(); } else { ret = CrawlStatus.FINISHED.toString(); } } } catch (FileNotFoundException e) { // TODO: handle exception } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (progressStatistics != null) { progressStatistics.close(); } } // File crawlReport = new File(this.jobsDir + FILE_SEPARATOR // + encodedJobName + FILE_SEPARATOR + "reports" + FILE_SEPARATOR // + "crawl-report.txt"); // if (crawlReport != null && crawlReport.canRead()) { // String crawlReportContent = FileUtils.readFileToString(crawlReport); // if (crawlReportContent.contains("crawl status: Finished")) { // ret = CrawlStatus.FINISHED.toString(); // } // } return ret; }
From source file:views.Student_Home.java
public Student_Home() { initComponents();/*from w w w . ja v a2 s. c o m*/ userLoggedIn.setText("User: " + projectManagementSystem.ProjectManagementGlobalSession.user_id); studentActions = new StudentActions(); taskModel = (DefaultTableModel) taskListTable.getModel(); ArrayList projectsList = studentActions.fetchProjets(); Date date = new Date(); projectModel = (DefaultTableModel) projectListTable.getModel(); for (int i = 0; i < projectsList.size(); i++) { Project project = (Project) projectsList.get(i); if (date.after(project.getEndDate())) { String[] str = { project.getProjectId(), project.getProjectDescription(), "Completed" }; projectModel.insertRow(projectModel.getRowCount(), str); } if (date.before(project.getStartDate())) { String[] str = { project.getProjectId(), project.getProjectDescription(), "Up coming Project" }; projectModel.insertRow(projectModel.getRowCount(), str); } else if (date.before(project.getEndDate())) { String[] str = { project.getProjectId(), project.getProjectDescription(), "In progress" }; projectModel.insertRow(projectModel.getRowCount(), str); } } populateTasks(); }
From source file:licenceexecuter.LicenceExecuter.java
private void run() throws Throwable { Date atualDate = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); ObKeyExecuter obKey = ControllerKey.decrypt(properties.getProperty("key")); if (atualDate.before(obKey.getDataLicenca())) { JOptionPane.showMessageDialog(null, "SUA LICENA INICIA DIA: " + sdf.format(obKey.getDataLicenca()), "ATENO", JOptionPane.ERROR_MESSAGE); return;/*from w w w . j a va 2s.c o m*/ } if (atualDate.after(obKey.getUltimaDataVerificada())) { try { if (atualDate.before(obKey.getDataValidade())) { Calendar calendar = Calendar.getInstance(); calendar.setTime(obKey.getDataValidade()); calendar.add(Calendar.DAY_OF_MONTH, -6); if (atualDate.after(calendar.getTime())) { String msg = String.format( "SUA LICENA VENCE NO DIA %s ENTRE COM A NOVA CHAVE OU CONTINUE.", sdf.format(obKey.getDataValidade())); JDialogRegister jDialogRegister = new JDialogRegister(msg); jDialogRegister.setVisible(true); if (jDialogRegister.getNewKey() != null && !jDialogRegister.getNewKey().isEmpty()) { ObKeyExecuter ob2 = register(jDialogRegister.getNewKey()); obKey = ob2 == null ? obKey : ob2; } } } else { String msg = String.format( "SUA LICENA VENCEU NO DIA %s ENTRE COM A NOVA CHAVE OU CONTINUE PARA SAIR.", sdf.format(obKey.getDataValidade())); JDialogRegister jDialogRegister = new JDialogRegister(msg); jDialogRegister.setVisible(true); if (jDialogRegister.getNewKey() != null && !jDialogRegister.getNewKey().isEmpty()) { ObKeyExecuter ob2 = register(jDialogRegister.getNewKey()); if (ob2 == null) { return; } obKey = ob2; } else { return; } } executeProgram(obKey); } finally { obKey.setUltimaDataVerificada(atualDate); updateKey(obKey); } } else { JOptionPane.showMessageDialog(null, "POSS?VEL ALTERAO NO RELGIO DO SISTEMA! VERIFIQUE", "ATENO", JOptionPane.ERROR_MESSAGE); } }
From source file:com.stratelia.webactiv.kmelia.PublicationImport.java
public void updatePublicationEndDate(String xmlFormName, String fieldName, String fieldValue, Date endDate) { String publicationToUpdateId = getPublicationId(xmlFormName, fieldName, fieldValue); PublicationPK publicationPK = new PublicationPK(publicationToUpdateId, spaceId, componentId); PublicationDetail pubDetail = kmeliaBm.getPublicationDetail(publicationPK); Date publicationEndDate = pubDetail.getEndDate(); if (publicationEndDate == null || publicationEndDate.after(endDate)) { pubDetail.setEndDate(endDate);//from w ww . j ava2 s . co m updatePublication(pubDetail, false); } }
From source file:be.e_contract.mycarenet.common.SessionKey.java
/** * Checks whether this MyCareNet session key still operates within its * validity period.// w w w.j av a 2 s . c o m * * @return */ public boolean isValid() { if (null == this.notBefore) { LOG.debug("no notBefore"); return false; } if (null == this.notAfter) { LOG.debug("no notAfter"); return false; } Date now = new Date(); if (now.before(this.notBefore)) { LOG.debug("session key not yet active"); LOG.debug("now: " + now); LOG.debug("notBefore: " + this.notBefore); return false; } if (now.after(this.notAfter)) { LOG.debug("session key expired"); return false; } return true; }
From source file:de.bund.bva.isyfact.benutzerverwaltung.sicherheit.BenutzerverwaltungAccessManager.java
private boolean benutzerAbgelaufen(BenutzerDaten benutzer) { Date letzteAnmeldung = benutzer.getLetzteAnmeldung(); if (letzteAnmeldung == null) { return false; }/* www .j av a 2 s.c o m*/ int ablaufFrist = konfiguration.getAsInteger( KonfigurationsSchluessel.ZUGRIFFSVERWALTUNG_BENUTZER_ABLAUFFRIST_IN_TAGEN, BENUTZER_ABLAUFFRIST); Date jetzt = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(letzteAnmeldung); calendar.add(Calendar.DATE, ablaufFrist); Date ablaufDatum = calendar.getTime(); return (jetzt.after(ablaufDatum)); }
From source file:com.rogchen.common.xml.UtilDateTime.java
public static Boolean currentDateDeviationIsThisRange(Date date, int senconds) { Calendar cuurnetCalendar1 = Calendar.getInstance(); cuurnetCalendar1.setTime(date);/*from ww w . ja va2 s . co m*/ cuurnetCalendar1.add(Calendar.SECOND, senconds); Calendar cuurnetCalendar2 = Calendar.getInstance(); cuurnetCalendar2.setTime(date); cuurnetCalendar2.add(Calendar.SECOND, -senconds); Date currentDate = new Date(); return currentDate.after(cuurnetCalendar2.getTime()) && currentDate.before(cuurnetCalendar1.getTime()); }
From source file:net.audumla.climate.bom.BOMHistoricalClimateObserver.java
synchronized public ClimateData getClimateData(Date date) { if (!invalidMonths.contains(Time.getMonthAndYear(date))) { if (!date.before(Time.getToday())) { throw new UnsupportedOperationException("JulianDate requested is in the future"); }/*from www . j av a2 s . co m*/ try { if (date.after(source.getLastRecord())) { throw new UnsupportedOperationException("JulianDate requested is after the last record"); } } catch (Exception ignored) { } ClimateData data = null; try { Date dayDate = yearMonthDay.parse(yearMonthDay.format(date)); data = historicalData.get(dayDate); if (data == null) { if (loadStationData(source.getId(), date)) { data = historicalData.get(dayDate); } } } catch (ParseException ignored) { } if (data != null) { return data; } } invalidMonths.add(Time.getMonthAndYear(date)); throw new UnsupportedOperationException("Cannot locate historical data " + yearMonthDay.format(date) + " for for station - " + source.getId()); }