List of usage examples for org.joda.time Days daysBetween
public static Days daysBetween(ReadablePartial start, ReadablePartial end)
Days
representing the number of whole days between the two specified partial datetimes. From source file:com.dnsoft.inmobiliaria.utils.CalculaMora.java
private int calculaDiasAtraso() { //se aplica mora a partir de esa fecha que incluye la tolerancia //int tolerancia = alquier.getContrato().getToleranciaMora(); Date vencimiento = alquier.getFechaVencimiento(); Calendar calendarVencimiento = Calendar.getInstance(); calendarVencimiento.setTime(vencimiento); //calendarTolerancia.add(Calendar.DAY_OF_YEAR, tolerancia); DateTime fechaVencimiento = new DateTime(calendarVencimiento); DateTime fechaPago = new DateTime(new Date()); int diasAtrasados = Days.daysBetween(fechaVencimiento, fechaPago).getDays(); return diasAtrasados; }
From source file:com.einzig.ipst2.portal.PortalResponded.java
License:Open Source License
@Override public int getDaysSinceResponse() { return Days.daysBetween(dateResponded, LocalDate.now()).getDays(); }
From source file:com.einzig.ipst2.portal.PortalResponded.java
License:Open Source License
public int getResponseTime() { return Days.daysBetween(getDateSubmitted(), dateResponded).getDays(); }
From source file:com.einzig.ipst2.portal.PortalSubmission.java
License:Open Source License
public int getDaysSinceResponse() { return Days.daysBetween(dateSubmitted, LocalDate.now()).getDays(); }
From source file:com.emc.storageos.systemservices.impl.eventhandler.connectemc.CallHomeEventManager.java
License:Open Source License
/** * Determines whether it's time to send a new heartbeat event. * /*from w ww .j a v a 2 s . c om*/ * @return boolean * @throws ParseException * @throws Exception */ public boolean doSendHeartBeat(LicenseInfoExt licenseInfo) throws ParseException { if (licenseInfo == null) { return true; } String lastHeartbeatDate = licenseInfo.getLastHeartbeatEventDate(); if (lastHeartbeatDate == null || lastHeartbeatDate.isEmpty() || lastHeartbeatDate.equals(CallHomeConstants.VALUE_NOT_SET)) { _log.info("There is no previous heartbeat event sent."); return true; } _log.info("Previous heartbeat event was sent on: {}", lastHeartbeatDate); // compare today's date to the date stored in the coordinator service. // If it's >= than // the HEARTBEART_EVENT_THRESHOLD, return true. SimpleDateFormat storedDate = new SimpleDateFormat(SERIALIZE_DATE_FORMAT); Date zkDate = storedDate.parse(lastHeartbeatDate); Date today = Calendar.getInstance().getTime(); int days = Days.daysBetween(new DateTime(zkDate), new DateTime(today)).getDays(); if (days > (CallHomeConstants.HEARTBEART_EVENT_THRESHOLD - 1)) { _log.info("It's been {} days since last heartbeat event was sent. Sending another one now. ", days); return true; } _log.info("Heartbeat event was sent {} days back. Will send another one in {} days.", days, (CallHomeConstants.HEARTBEART_EVENT_THRESHOLD - days)); return false; }
From source file:com.emc.storageos.systemservices.impl.eventhandler.connectemc.CallHomeEventManager.java
License:Open Source License
/** * Determines whether a registration event has already been sent. * /*from w w w . ja va2 s . c om*/ * @return boolean * @throws Exception */ public boolean doSendRegistration(LicenseInfoExt licenseInfo) throws Exception { if (licenseInfo == null) { return true; } String registrationDate = licenseInfo.getLastRegistrationEventDate(); if (registrationDate == null || registrationDate.isEmpty() || registrationDate.equals(CallHomeConstants.VALUE_NOT_SET)) { _log.info("There is no previous registration event sent."); return true; } _log.info("Previous registration event was sent on: {}", registrationDate); // compare today's date to the date stored in the coordinator service. // If it's >= than // the HEARTBEART_EVENT_THRESHOLD, return true. SimpleDateFormat storedDate = new SimpleDateFormat(SERIALIZE_DATE_FORMAT); Date zkDate = storedDate.parse(registrationDate); Date today = Calendar.getInstance().getTime(); int days = Days.daysBetween(new DateTime(zkDate), new DateTime(today)).getDays(); if (days > (CallHomeConstants.REGISTRATION_EVENT_THRESHOLD - 1)) { _log.info("It's been {} days since last registration event was sent. Sending another one now. ", days); return true; } _log.info("Registration event was sent {} days back. Will send another one in {} days.", days, (CallHomeConstants.REGISTRATION_EVENT_THRESHOLD - days)); return false; }
From source file:com.emc.storageos.systemservices.impl.eventhandler.connectemc.CallHomeEventManager.java
License:Open Source License
/** * Determines whether it's time to send a new capacity exceeded event. * /*from ww w . ja va 2 s .co m*/ * @return boolean * @throws Exception */ public boolean doSendCapicityExceeded(LicenseInfoExt licenseInfo) throws Exception { if (licenseInfo == null) { return true; } String lastCapacityExceedDate = licenseInfo.getLastCapacityExceededEventDate(); if (lastCapacityExceedDate == null || lastCapacityExceedDate.isEmpty() || lastCapacityExceedDate.equals(CallHomeConstants.VALUE_NOT_SET)) { _log.info("There is no previous capacity-exceeded event sent."); return true; } _log.info("Previous capacity-exceeded event was sent on: {}", lastCapacityExceedDate); // compare today's date to the date stored in zookeeper. If it's >= than // the LICENSE_EXPIRATION_EVENT_THRESHOLD, return true. SimpleDateFormat storedDate = new SimpleDateFormat(SERIALIZE_DATE_FORMAT); Date zkDate = storedDate.parse(lastCapacityExceedDate); Date today = Calendar.getInstance().getTime(); int days = Days.daysBetween(new DateTime(zkDate), new DateTime(today)).getDays(); if (days > (CallHomeConstants.CAPACITY_EXCEEDED_EVENT_THRESHOLD - 1)) { _log.info("It's been {} days since last capacity-exceeded event was sent. Sending another one now. ", days); return true; } _log.info("Capacity-exceeded event was sent {} days back. Will send another one in {} days.", days, (CallHomeConstants.CAPACITY_EXCEEDED_EVENT_THRESHOLD - days)); return false; }
From source file:com.emc.storageos.systemservices.impl.eventhandler.connectemc.CallHomeEventManager.java
License:Open Source License
/** * Determines whether it's time to send a new license expiration event. * /*from w ww .ja v a 2 s. c om*/ * @return boolean * @throws Exception */ public boolean doSendLicenseExpiration(LicenseInfoExt licenseInfo) throws Exception { if (licenseInfo == null) { return true; } String lastExpirationDate = licenseInfo.getLastLicenseExpirationDateEventDate(); if (lastExpirationDate == null || lastExpirationDate.isEmpty() || lastExpirationDate.equals(CallHomeConstants.VALUE_NOT_SET)) { _log.info("There is no previous license-expiration event sent."); return true; } _log.info("Previous license-expiration event was sent on: {}", lastExpirationDate); // compare today's date to the date stored in zookeeper. If it's >= than // the LICENSE_EXPIRATION_EVENT_THRESHOLD, return true. SimpleDateFormat storedDate = new SimpleDateFormat(SERIALIZE_DATE_FORMAT); Date zkDate = storedDate.parse(lastExpirationDate); Date today = Calendar.getInstance().getTime(); int days = Days.daysBetween(new DateTime(zkDate), new DateTime(today)).getDays(); if (days > (CallHomeConstants.LICENSE_EXPIRATION_EVENT_THRESHOLD - 1)) { _log.info("It's been {} days since last license-expiration event was sent. Sending another one now. ", days); return true; } _log.info("License-expired event was sent {} days back. Will send another one in {} days.", days, (CallHomeConstants.LICENSE_EXPIRATION_EVENT_THRESHOLD - days)); return false; }
From source file:com.emc.storageos.systemservices.impl.licensing.LicenseManagerImpl.java
License:Open Source License
protected static boolean isExpired(String expiryDateString) { // if date expires is empty, check to see if the product is licensed. If // it is licensed and the _dateExpires is false, the license has expired. // This is because the ELM software does not set the date expires when // it notices a license is invalid. This license must have expired // sometime between server restarts. The product is technically // licenses..but in an expired state. if (expiryDateString == null) { return false; }/*from w w w . j av a 2 s. c om*/ if (!expiryDateString.equalsIgnoreCase(PERMANENT_LICENSE)) { SimpleDateFormat sdf = new SimpleDateFormat(EXPIRE_DATE_FORMAT); Date expireDate = null; try { expireDate = sdf.parse(expiryDateString); Date today = Calendar.getInstance().getTime(); int days = Days.daysBetween(new DateTime(expireDate), new DateTime(today)).getDays(); if (days > 0) { return true; } } catch (ParseException e) { _log.error("Parse Exception in License::isExpired() : " + e.getMessage()); } } return false; }
From source file:com.espian.ticktock.CountdownFragment.java
License:Apache License
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (getArguments() == null) throw new IllegalArgumentException("No args supplied for fragment"); try {//from w w w . ja va2 s . c om final Date date = DateFormat.getDateInstance(DateFormat.LONG).parse(getArguments().getString("date")); mIdAsString = getArguments().getString(BaseColumns._ID); mLabelView.setText(mLabel = getArguments().getString("label")); mDateView.setText(DateFormat.getDateInstance(DateFormat.MEDIUM).format(date)); mHelper = new LoadHideHelper(this); new Thread(new Runnable() { @Override public void run() { // Requires an ugly fudge because, for some reason, the Days class accesses // the disk through random access, which throws errors with StrictMode. int days = Days.daysBetween(new DateTime(new Date()), new DateTime(date)).getDays(); Bundle b = new Bundle(); b.putString("result", String.valueOf(days + 1)); Message m = Message.obtain(asyncHandler); m.setData(b); asyncHandler.sendMessage(m); } }).start(); } catch (ParseException e) { Toast.makeText(getActivity(), "Malformed date was stored", Toast.LENGTH_SHORT).show(); e.printStackTrace(); } //getActivity().getLoaderManager().initLoader(TickTockProvider.LOADER_SINGLE_ITEM, getArguments(), this); }