List of usage examples for org.apache.commons.lang3.time DateUtils isSameDay
public static boolean isSameDay(final Calendar cal1, final Calendar cal2)
Checks if two calendar objects are on the same day ignoring time.
28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true.
From source file:fi.foyt.fni.view.users.UsersProfileBackingBean.java
private Event createEventPojo(IllusionEvent event) { if (DateUtils.isSameDay(event.getStart(), event.getEnd())) { Date date = DateUtils.truncate(event.getStart(), Calendar.DAY_OF_MONTH); long startDiff = event.getStart().getTime() - date.getTime(); long endDiff = event.getEnd().getTime() - date.getTime(); Date startTime = startDiff > 0 ? new Date(startDiff) : null; Date endTime = endDiff > 0 ? new Date(endDiff) : null; return new Event(event.getName(), event.getUrlName(), event.getDescription(), event.getStart(), startTime, event.getEnd(), endTime); } else {/* w w w. j a v a 2s . com*/ return new Event(event.getName(), event.getUrlName(), event.getDescription(), event.getStart(), null, event.getEnd(), null); } }
From source file:com.premiumminds.billy.core.services.builders.impl.GenericInvoiceEntryBuilderImpl.java
protected void validateValues() throws ValidationException { MathContext mc = BillyMathContext.get(); GenericInvoiceEntryEntity e = this.getTypeInstance(); for (Tax t : e.getProduct().getTaxes()) { if (this.daoContext.isSubContext(t.getContext(), this.context)) { Date taxDate = e.getTaxPointDate() == null ? new Date() : e.getTaxPointDate(); if (DateUtils.isSameDay(t.getValidTo(), taxDate) || t.getValidTo().after(taxDate)) { e.getTaxes().add(t);//from w ww . j a v a2 s . c om } } } if (e.getTaxes().isEmpty()) { throw new ValidationException( GenericInvoiceEntryBuilderImpl.LOCALIZER.getString("exception.invalid_taxes")); } e.setUnitDiscountAmount(BigDecimal.ZERO); // TODO if (e.getUnitAmountWithTax() != null) { BigDecimal unitAmountWithoutTax = e.getUnitAmountWithTax(); BigDecimal unitTaxAmount = BigDecimal.ZERO; for (Tax t : this.getTypeInstance().getTaxes()) { switch (t.getTaxRateType()) { case FLAT: unitAmountWithoutTax = unitAmountWithoutTax.subtract(t.getValue(), mc); unitTaxAmount = unitTaxAmount.add(t.getValue(), mc); break; case PERCENTAGE: unitAmountWithoutTax = e.getUnitAmountWithTax().divide( BigDecimal.ONE.add(t.getPercentageRateValue().divide(new BigDecimal("100"), mc), mc), mc); unitTaxAmount = unitTaxAmount.add(e.getUnitAmountWithTax().subtract(unitAmountWithoutTax, mc), mc); break; default: break; } } e.setUnitAmountWithoutTax(unitAmountWithoutTax); e.setUnitTaxAmount(unitTaxAmount); // Minus discounts e.setUnitAmountWithoutTax(unitAmountWithoutTax.subtract(e.getUnitDiscountAmount(), mc)); } else { BigDecimal unitAmountWithTax = e.getUnitAmountWithoutTax(); BigDecimal unitTaxAmount = BigDecimal.ZERO; for (Tax t : this.getTypeInstance().getTaxes()) { switch (t.getTaxRateType()) { case FLAT: unitAmountWithTax = unitAmountWithTax.add(t.getValue(), mc); unitTaxAmount = unitTaxAmount.add(t.getValue(), mc); break; case PERCENTAGE: unitTaxAmount = unitTaxAmount.add(e.getUnitAmountWithoutTax() .multiply(t.getPercentageRateValue(), mc).divide(new BigDecimal("100"), mc), mc); unitAmountWithTax = unitAmountWithTax.add(unitTaxAmount, mc); break; default: break; } } e.setUnitAmountWithTax(unitAmountWithTax); e.setUnitTaxAmount(unitTaxAmount); } e.setAmountWithTax(this.getTypeInstance().getUnitAmountWithTax().multiply(e.getQuantity(), mc)); e.setAmountWithoutTax(this.getTypeInstance().getUnitAmountWithoutTax().multiply(e.getQuantity(), mc)); e.setTaxAmount(this.getTypeInstance().getUnitTaxAmount().multiply(e.getQuantity(), mc)); e.setDiscountAmount(this.getTypeInstance().getUnitDiscountAmount().multiply(e.getQuantity(), mc)); }
From source file:models.Issue.java
public String until() { if (dueDate == null) { return null; }/*from w w w .j a va 2 s . c o m*/ Date now = JodaDateUtil.now(); if (DateUtils.isSameDay(now, dueDate)) { return Messages.get("common.time.today"); } else if (isOverDueDate()) { return Messages.get("common.time.default.day", JodaDateUtil.localDaysBetween(dueDate, now)); } else { return Messages.get("common.time.default.day", JodaDateUtil.localDaysBetween(now, dueDate)); } }
From source file:com.marand.thinkmed.medications.business.impl.DefaultMedicationsBo.java
@Override public int getTherapyConsecutiveDay(final DateTime therapyStart, final DateTime therapyDay, final DateTime currentTime, final Integer pastDaysOfTherapy) { final int pastDays = pastDaysOfTherapy != null ? pastDaysOfTherapy : 0; //today//from w ww.ja va 2s. com if (DateUtils.isSameDay(therapyDay.toDate(), currentTime.toDate())) { return Days.daysBetween(therapyStart, currentTime).getDays() + pastDays; } return Days.daysBetween(therapyStart.withTimeAtStartOfDay(), therapyDay.withTimeAtStartOfDay()).getDays() + pastDays; }
From source file:com.inkubator.hrm.service.impl.WtScheduleShiftServiceImpl.java
@Override @Transactional(readOnly = true, isolation = Isolation.REPEATABLE_READ, propagation = Propagation.SUPPORTS, timeout = 50) public List<Date> getAllWorkingDaysBetween(Long empDataId, Date startDate, Date endDate) throws Exception { EmpData empData = empDataDao.getEntiyByPK(empDataId); List<Date> workingDays = new ArrayList<Date>(); List<TempJadwalKaryawan> tempJadwalKaryawans = new ArrayList<TempJadwalKaryawan>(); //loop date-nya, check jadwal berdasarkan kelompok kerja for (Date loop = startDate; loop.before(endDate) || DateUtils.isSameDay(loop, endDate); loop = DateUtils.addDays(loop, 1)) { TempJadwalKaryawan jadwal = Lambda.selectFirst(tempJadwalKaryawans, Lambda.having(Lambda.on(TempJadwalKaryawan.class).getTanggalWaktuKerja().getTime(), Matchers.equalTo(loop.getTime()))); if (jadwal == null) { //jika tidak terdapat jadwal kerja di date tersebut, maka generate jadwal kerja temporary-nya, lalu check kembali jadwal kerja-nya List<TempJadwalKaryawan> jadwalKaryawans = this .getAllScheduleForView(empData.getWtGroupWorking().getId(), loop, null); tempJadwalKaryawans.addAll(jadwalKaryawans); jadwal = Lambda.selectFirst(tempJadwalKaryawans, Lambda.having(Lambda.on(TempJadwalKaryawan.class).getTanggalWaktuKerja().getTime(), Matchers.equalTo(loop.getTime()))); }/*www . j a va2s . c o m*/ //selain "OFF"(hari libur) berarti termasuk jam kerja if (jadwal != null) { if (!StringUtils.equals(jadwal.getWtWorkingHour().getCode(), "OFF")) { workingDays.add(jadwal.getTanggalWaktuKerja()); } } } return workingDays; }
From source file:co.com.soinsoftware.hotelero.view.JFRoom.java
private boolean validateInitialDate(final boolean isCheckIn, final String errorMessage) { boolean isValid = false; final Date currentDate = new Date(); final Date initialDate = this.jdcInitialDate.getDate(); if (DateUtils.isSameDay(currentDate, initialDate)) { isValid = true;/* w ww . j av a 2s . c o m*/ } else { isValid = (isCheckIn) ? false : true; } if (!isValid) { ViewUtils.showMessage(this, errorMessage, ViewUtils.TITLE_REQUIRED_FIELDS, JOptionPane.ERROR_MESSAGE); } return isValid; }
From source file:co.com.soinsoftware.hotelero.view.JFRoom.java
private boolean validateFinalDate() { boolean isValid = true; final Date initialDate = this.jdcInitialDate.getDate(); final Date finalDate = this.jdcFinalDate.getDate(); if (DateUtils.isSameDay(initialDate, finalDate) || initialDate.after(finalDate)) { isValid = false;//from w w w . j a va 2 s . c o m } if (!isValid) { ViewUtils.showMessage(this, MSG_FINAL_DATE_EQUALS_INITIAL_DATE, ViewUtils.TITLE_REQUIRED_FIELDS, JOptionPane.ERROR_MESSAGE); } return isValid; }
From source file:co.com.soinsoftware.hotelero.view.JFRoom.java
private void refreshNotEnabledSet() { final Date initialDate = this.jdcInitialDate.getDate(); final Date finalDate = this.jdcFinalDate.getDate(); this.notEnabledSet = this.invoiceController.selectNotEnabled(initialDate, finalDate); if (DateUtils.isSameDay(initialDate, new Date())) { this.addNotEnabledForCurrentDay(); }// w w w . ja va 2s .co m this.setBackgroudForNotEnabledRooms(); }
From source file:com.inkubator.hrm.service.impl.WtScheduleShiftServiceImpl.java
@Override @Cacheable(value = "allRegulerOffDaysBetween") @Transactional(readOnly = true, isolation = Isolation.REPEATABLE_READ, propagation = Propagation.SUPPORTS, timeout = 50) public Set<Date> getAllRegulerOffDaysBetween(Date startDate, Date endDate) throws Exception { Set<Date> offDays = new HashSet<Date>(); List<TempJadwalKaryawan> tempJadwalKaryawans = new ArrayList<TempJadwalKaryawan>(); WtGroupWorking workingGroup = wtGroupWorkingDao.getByCode(HRMConstant.WORKING_GROUP_CODE_DEFAULT); //loop date-nya, check jadwal berdasarkan kelompok kerja if (workingGroup != null) { for (Date loop = startDate; loop.before(endDate) || DateUtils.isSameDay(loop, endDate); loop = DateUtils.addDays(loop, 1)) { TempJadwalKaryawan jadwal = Lambda.selectFirst(tempJadwalKaryawans, Lambda.having(Lambda.on(TempJadwalKaryawan.class).getTanggalWaktuKerja().getTime(), Matchers.equalTo(loop.getTime()))); if (jadwal == null) { //jika tidak terdapat jadwal kerja di date tersebut, maka generate jadwal kerja temporary-nya, lalu check kembali jadwal kerja-nya List<TempJadwalKaryawan> jadwalKaryawans = this.getAllScheduleForView(workingGroup.getId(), loop, null);//from www. ja va2 s . com tempJadwalKaryawans.addAll(jadwalKaryawans); jadwal = Lambda.selectFirst(tempJadwalKaryawans, Lambda.having(Lambda.on(TempJadwalKaryawan.class).getTanggalWaktuKerja().getTime(), Matchers.equalTo(loop.getTime()))); } //hanya yg "OFF"(hari libur) saja if (jadwal != null) { if (StringUtils.equals(jadwal.getWtWorkingHour().getCode(), "OFF")) { offDays.add(jadwal.getTanggalWaktuKerja()); } } } } //loop holiday nya List<WtHoliday> listHoliday = wtHolidayDao.getBetweenDate(startDate, endDate); for (WtHoliday holiday : listHoliday) { offDays.add(holiday.getHolidayDate()); } return offDays; }
From source file:gov.nih.nci.firebird.service.annual.registration.AnnualRegistrationServiceBeanTest.java
@Test public void testSetRenewalDateIfNecessary_NoDueDate() { AnnualRegistration registration = new AnnualRegistration(); bean.setRenewalDateIfNecessary(registration); Date expectedDate = DateUtils.addYears(new Date(), 1); assertTrue(DateUtils.isSameDay(expectedDate, registration.getRenewalDate())); }