List of usage examples for java.util Date before
public boolean before(Date when)
From source file:com.jinhe.tss.framework.license.LicenseManager.java
public void loadLicenses() { if (licenses != null) return;//from www.ja va2 s . c o m licenses = new ArrayList<License>(); String files[] = new File(LicenseFactory.LICENSE_DIR).list(); for (int i = 0; i < files.length; i++) { String filename = files[i]; File file = new File(LicenseFactory.LICENSE_DIR, filename); if (file.isDirectory() || !filename.endsWith(".license")) { continue; } try { License license = License.fromConfigFile(filename); Date expiresDate = license.expiresDate; if (expiresDate != null && expiresDate.before(new Date())) { log.error("license \"" + file.getName() + "\" ?."); continue; } if (!validate(license)) { log.error("license \"" + file.getName() + "\" ??."); continue; } licenses.add(license); } catch (Exception e) { log.error("?license" + filename, e); } } if (licenses.isEmpty()) { log.error("???license."); } return; }
From source file:net.sf.mmm.persistence.impl.hibernate.EnversTest.java
protected void readAgainAndDelete(Long fooId) { assertNotNull(fooId);//from w w w .ja v a 2 s . c o m Date now = new Date(); RevisionedPersistenceManager persistenceManager = getPersistenceManager(); DummyRevisionedFooEntityDao fooManager = (DummyRevisionedFooEntityDao) persistenceManager .getDao(DummyRevisionedFooEntity.class); DummyRevisionedFooEntity foo = fooManager.load(fooId, RevisionedEntity.LATEST_REVISION); assertEquals("It was magic", foo.getValue()); List<RevisionMetadata> history = fooManager.getRevisionHistoryMetadata(fooId); assertEquals(2, history.size()); RevisionMetadata firstRevision = history.get(0); assertEquals(TestUser.DEFAULT_NAME, firstRevision.getCreator()); RevisionMetadata secondRevision = history.get(1); assertEquals(TestUser.DEFAULT_NAME, firstRevision.getCreator()); assertEquals(firstRevision.getRevision().longValue() + 1, secondRevision.getRevision()); Date firstDate = firstRevision.getDate(); Date secondDate = secondRevision.getDate(); assertTrue(firstDate.before(secondDate)); assertTrue(secondDate.before(now)); // duration from first revision to now in millis long delta = now.getTime() - firstDate.getTime(); assertTrue(delta < 6000L); DummyRevisionedFooEntity fooHistory = fooManager.load(fooId, firstRevision.getRevision()); assertNotNull(fooHistory); assertEquals("This is magic", fooHistory.getValue()); fooManager.delete(foo); }
From source file:net.duckling.ddl.service.resource.impl.PageLockProvider.java
public synchronized boolean isTimeOut(Date lastAccess, Date now) { Date timeOut = DateUtils.addMinutes(lastAccess, this.timeOutInterval); return timeOut.before(now); }
From source file:com.jonschang.investing.QVSNNTest.java
@SuppressWarnings(value = "unchecked") @Test/*www .java2 s . c o m*/ public void testQVSNN() throws Exception { try { trainingStart = new SimpleDateFormat("MM/dd/yyyy HH:mm").parse("10/22/2007 16:00"); trainingEnd = new SimpleDateFormat("MM/dd/yyyy HH:mm").parse("4/22/2009 16:00"); runEnd = new SimpleDateFormat("MM/dd/yyyy HH:mm").parse("10/22/2009 16:00"); DatePublisher datePublisher = new GenericDatePublisher(); turnOffLogging(); NetworkBuilder<FeedForward, StockQuote, Stock> builder = new NetworkBuilder_0_0_1a(datePublisher); builder.setTrainingStart(trainingStart); builder.setTrainingEnd(trainingEnd); builder.setRunEnd(runEnd); BackPropagation trainer = (BackPropagation) builder.getTrainer(); trainer.setDesiredMSE(0.002); StockService stockService = (StockService) Investing.instance().getQuotableServiceFactory() .get(Stock.class); for (QuotePublisher pub : builder.getPublishers()) { pub.setQuotable(stockService.get("MDR")); } trainer.train(); Logger.getLogger(this.getClass()) .info("currentMSE = " + trainer.getCurrentMSE() + ", desiredMSE = " + trainer.getDesiredMSE()); for (QuotePublisher pub : builder.getPublishers()) { pub.setQuotable(stockService.get("MDR")); } Date date = (Date) trainingEnd.clone(); datePublisher.setDate(date); MathVector output; while (date.before(runEnd)) { trainer.getNetwork().calculateResponse(); output = trainer.getNetwork().getLastOutput(); if (output != null && (output.getData().get(0) > .85 || output.getData().get(1) > .85)) Logger.getLogger(this.getClass()).info(date + " - " + output.getData()); TimeInterval.DAY.add(date); datePublisher.updateHasDates(); } } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:emcali.ami.control.webservice.IPTVAMIWebService.java
private JSONObject getData(JSONObject req, JSONObject resp) { Calendar cal = new GregorianCalendar(); DateFormat dateformat = new SimpleDateFormat("dd-MM-YYYY"); Date today = cal.getTime();/* w w w. j a v a 2 s .c om*/ cal.add(Calendar.DAY_OF_MONTH, -11); Date tendaysago = cal.getTime(); String telcoid = (String) req.get("suscriptor"); TelcoInfoJpaController tijc = new TelcoInfoJpaController(utx, emf); TelcoInfo ti = tijc.findTelcoInfo(Long.parseLong(telcoid)); try { JSONObject data = new JSONObject(); JSONArray consumos = new JSONArray(); AmyMedidores med = ti.getFkAmyMedidores(); ComercialClientes cc = ti.getFkComercialClientes(); List<AmyConsumos> ac = med.getAmyConsumosList(); data.put("id_cliente", cc.getIdClientes()); data.put("nombre_cliente", cc.getNombreClientes()); data.put("direccion", cc.getDireccion()); data.put("serial_medidor", med.getSerial()); for (AmyConsumos amic : ac) { if (amic.getFkAmyInterval().getIntervalo().equals("Dia")) { Date fechacons = amic.getFechaConsumo(); if ((fechacons.compareTo(tendaysago) > 0) && fechacons.before(today)) { JSONObject consumo = new JSONObject(); consumo.put("consumo", amic.getConsumo()); consumo.put("fecha", dateformat.format(amic.getFechaConsumo())); consumos.add(consumo); } } } data.put("consumos", consumos); resp.put("data", data); } catch (NullPointerException ex) { resp.put("message", "Invalid Telco user"); resp.put("type", "error"); } return resp; }
From source file:eu.annocultor.converters.solr.SolrPeriodsTagger.java
Date minDate(Date one, Date two) { if (one == null) { return two; }/*from www. j a va 2s. c o m*/ if (two == null) { return one; } if (one.before(two)) { return one; } return two; }
From source file:net.mikaboshi.intra_mart.tools.log_stats.report.SessionMap.java
/** * ?/* ww w.j a v a 2 s .c om*/ * @param sessionId * @param date */ public void putLastAccessDate(String sessionId, Date date) { if (!isValidId(sessionId) || date == null) { return; } Date prev = this.lastAccessSessionMap.get(sessionId); if (prev == null || prev.before(date)) { this.lastAccessSessionMap.put(sessionId, date); } }
From source file:de.codesourcery.planning.impl.AbstractJob.java
@Override public final Duration getDurationFrom(Date date) { final Date jobStartDate = getStartDate(); if (isAfterOrOn(jobStartDate, date)) { return getDuration(); }//from www . j a v a2 s . co m final Date endDate = Duration.add(jobStartDate, getDuration()); if (endDate.before(date)) { return Duration.ZERO; } return new Duration(date, endDate); }
From source file:org.dspace.orm.entity.ResourcePolicy.java
@Transient public boolean isDateValid() { Date sd = getStartDate();//from w w w . j a v a 2s. c o m Date ed = getEndDate(); // if no dates set, return true (most common case) if ((sd == null) && (ed == null)) { return true; } // one is set, now need to do some date math Date now = new Date(); // check start date first if (sd != null && now.before(sd)) { // start date is set, return false if we're before it return false; } // now expiration date if (ed != null && now.after(ed)) { // end date is set, return false if we're after it return false; } // if we made it this far, start < now < end return true; // date must be okay }