List of usage examples for java.util Calendar compareTo
private int compareTo(long t)
From source file:org.hansel.myAlert.Rastreo.java
@Override public void onResume() { super.onResume(); long time = PreferenciasHancel.getAlarmStartDate(getActivity()); if (time != 0) { Calendar currentTime = Calendar.getInstance(); Calendar alarmTime = Calendar.getInstance(); alarmTime.setTimeInMillis(time); //comparamos la fecha para saber si ya esta corriendo la alarma if (alarmTime.compareTo(currentTime) != -1) //-1 si es antes aun podemos modificar la alarma {/*from w w w . j a va 2 s . c o m*/ showCurrentTrackInfo(true); } txtCurrentTrackInfo.setText(Util.getSimpleDateFormatTrack(alarmTime)); } corriendo = Util.isMyServiceRunning(getActivity().getApplicationContext()); setupButtonText(); }
From source file:egovframework.rte.itl.webservice.EgovWebService.java
@Override protected EgovIntegrationMessage doSend(EgovIntegrationMessage requestMessage) { LOG.debug("EgovWebSerivce doSend (requestMessage = " + requestMessage + ")"); // ?./* w w w . jav a2s. c o m*/ if (integrationDefinition.isUsing() == false) { LOG.info("Integration (id = \"" + id + "\") is not usable"); return new EgovWebServiceMessage(new EgovWebServiceMessageHeader(defaultHeader) { { setResultCode(ResultCode.NOT_USABLE_INTEGRATION); } }); } // ? ?. boolean validFrom = true; boolean validTo = true; Calendar now = Calendar.getInstance(); if (integrationDefinition.getValidateFrom() != null) { validFrom = (integrationDefinition.getValidateFrom().compareTo(now) <= 0); } if (integrationDefinition.getValidateTo() != null) { validTo = (now.compareTo(integrationDefinition.getValidateTo()) <= 0); } if (validFrom == false || validTo == false) { LOG.info("Integration (id = \"" + id + "\") is invalid at " + now + " (validFrom = " + integrationDefinition.getValidateFrom() + ", validTo = " + integrationDefinition.getValidateTo() + ")"); return new EgovWebServiceMessage(new EgovWebServiceMessageHeader(defaultHeader) { { setResultCode(ResultCode.INVALID_TIME); } }); } // ? ?. if (integrationDefinition.getProvider().isUsing() == false) { LOG.info("Integration (id = \"" + id + "\")'s provider service " + "is not usable"); return new EgovWebServiceMessage(new EgovWebServiceMessageHeader(defaultHeader) { { setResultCode(ResultCode.NOT_USABLE_SERVICE); } }); } // ? requestMessage.getHeader().setRequestSendTime(now); // & ? EgovIntegrationMessage responseMessage = client.service(requestMessage); // ? ? responseMessage.getHeader().setResponseReceiveTime(Calendar.getInstance()); return responseMessage; }
From source file:com.sap.dirigible.runtime.registry.RegistryServlet.java
private boolean setCacheHeaders(IEntity entity, HttpServletRequest request, HttpServletResponse response) throws IOException { boolean cached = false; IEntityInformation entityInformation = entity.getInformation(); String modifiedSinceHeader = request.getHeader(IF_MODIFIED_SINCE_HEADER); if ((entityInformation != null)) { Calendar lastModified = getCalendar(entityInformation.getModifiedAt()); if ((!StringUtils.isEmpty(modifiedSinceHeader))) { Calendar modifiedSince = getCalendar(DateUtils.parseDate(modifiedSinceHeader)); if (lastModified.compareTo(modifiedSince) <= 0) { Calendar expires = getCalendar(lastModified); expires.add(Calendar.MONTH, 1); response.setDateHeader(EXPIRES_HEADER, expires.getTimeInMillis()); response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); cached = true;/* ww w . ja v a 2 s .c o m*/ } } response.setDateHeader(LAST_MODIFIED_HEADER, lastModified.getTimeInMillis()); } return cached; }
From source file:simpleserver.bot.BotController.java
public void spawnAt(int spawnMonth, int spawnDay) { Calendar now = new GregorianCalendar(); Calendar spawn = new GregorianCalendar(now.get(Calendar.YEAR), spawnMonth, spawnDay); int month = now.get(Calendar.MONTH); int day = now.get(Calendar.DAY_OF_MONTH); if (month == spawnMonth && day == spawnDay) { try {/* w w w. j a v a 2 s . com*/ connect(new Herobrine(server)); } catch (ConnectException e) { } } else if (spawn.compareTo(now) > 0) { now.set(Calendar.DAY_OF_MONTH, day + 5); if (spawn.compareTo(now) < 0) { timer = new Timer(); timer.schedule(new HerobrineSpawner(), spawn.getTime()); } } }
From source file:com.wildplot.android.ankistats.CollectionData.java
private void _updateCutoff() { // calculate days since col created and store in mToday mToday = 0;// w w w . j a v a 2 s.co m Calendar crt = GregorianCalendar.getInstance(); crt.setTimeInMillis(mCrt * 1000); // creation time (from crt as stored in database) Calendar fromNow = GregorianCalendar.getInstance(); // decremented towards crt // code to avoid counting years worth of days int yearSpan = fromNow.get(Calendar.YEAR) - crt.get(Calendar.YEAR); if (yearSpan > 1) { // at least one full year has definitely lapsed since creation int toJump = 365 * (yearSpan - 1); fromNow.add(Calendar.YEAR, -toJump); if (fromNow.compareTo(crt) < 0) { // went too far, reset and do full count fromNow = GregorianCalendar.getInstance(); } else { mToday += toJump; } } // count days backwards while (fromNow.compareTo(crt) > 0) { fromNow.add(Calendar.DAY_OF_MONTH, -1); if (fromNow.compareTo(crt) >= 0) { mToday++; } } crt.add(Calendar.DAY_OF_YEAR, mToday + 1); mDayCutoff = crt.getTimeInMillis() / 1000; }
From source file:org.kuali.kra.committee.service.impl.CommitteeServiceImpl.java
/** * Is it OK to schedule a review for the given committee and schedule? * @param committee/* ww w . ja v a2 s . c o m*/ * @param schedule * @return */ protected boolean isOkayToScheduleReview(Committee committee, CommitteeSchedule schedule) { Calendar now = getCalendar(new Date()); Calendar scheduleCalendar = getCalendar(schedule.getScheduledDate()); // now.add(Calendar.DAY_OF_MONTH, committee.getAdvancedSubmissionDaysRequired()); boolean dateRangeOK = now.compareTo(getCalendar(schedule.getProtocolSubDeadline())) <= 0; boolean statusOK = "Scheduled".equals(schedule.getScheduleStatus().getDescription()); return dateRangeOK && statusOK; }
From source file:nodomain.freeyourgadget.gadgetbridge.service.devices.hplus.HPlusHandlerThread.java
@Override public void run() { mQuit = false;//from w w w .java 2 s. com sync(); long waitTime = 0; while (!mQuit) { if (waitTime > 0) { synchronized (waitObject) { try { waitObject.wait(waitTime); } catch (InterruptedException e) { e.printStackTrace(); } } } if (mQuit) { break; } if (!mHPlusSupport.getDevice().isConnected()) { quit(); break; } Calendar now = GregorianCalendar.getInstance(); if (now.compareTo(mGetDaySlotsTime) > 0) { requestNextDaySlots(); } if (now.compareTo(mGetSleepTime) > 0) { requestNextSleepData(); } if (now.compareTo(mGetDaySummaryTime) > 0) { requestDaySummaryData(); } now = GregorianCalendar.getInstance(); waitTime = Math.min(mGetDaySummaryTime.getTimeInMillis(), Math.min(mGetDaySlotsTime.getTimeInMillis(), mGetSleepTime.getTimeInMillis())) - now.getTimeInMillis(); } }
From source file:com.example.android.directboot.alarms.Alarm.java
@Override public int compareTo(@NonNull Alarm other) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MONTH, month); calendar.set(Calendar.DATE, date); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minute); Calendar otherCal = Calendar.getInstance(); otherCal.set(Calendar.MONTH, other.month); otherCal.set(Calendar.DATE, other.date); otherCal.set(Calendar.HOUR_OF_DAY, other.hour); otherCal.set(Calendar.MINUTE, other.minute); return calendar.compareTo(otherCal); }
From source file:com.ecofactor.qa.automation.consumerapi.ThermostatRuntimeSavings_Test.java
/** * Check if month gaps exists between calendar. * @param calendar1 the calendar1/*from ww w . j a v a2 s . com*/ * @param calendar2 the calendar2 * @return true, if successful */ private boolean checkIfMonthGapsExistsBetweenCalendar(final Calendar calendar1, final Calendar calendar2) { calendar1.add(Calendar.MONTH, 1); return calendar1.compareTo(calendar2) != 0; }
From source file:org.kuali.kra.common.committee.service.impl.CommitteeServiceImplBase.java
/** * Is it OK to schedule a review for the given committee and schedule? * @param committee/* ww w .j av a 2 s . c o m*/ * @param schedule * @return */ protected boolean isOkayToScheduleReview(CMT committee, CS schedule) { Calendar now = getCalendar(new Date()); Calendar scheduleCalendar = getCalendar(schedule.getScheduledDate()); // now.add(Calendar.DAY_OF_MONTH, committee.getAdvancedSubmissionDaysRequired()); boolean dateRangeOK = now.compareTo(getCalendar(schedule.getProtocolSubDeadline())) <= 0; boolean statusOK = "Scheduled".equals(schedule.getScheduleStatus().getDescription()); return dateRangeOK && statusOK; }