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:com.googlecode.commons.swing.component.datetime.MiniDateCalendar.java
public void refresh() { final Date value = getValue(); final Date startOfMonth = DateUtils2.getStartOfMonth(value); final Date endOfMonth = DateUtils2.getEndOfMonth(value); final long daysOfMonth = DateUtils.getFragmentInDays(endOfMonth, Calendar.MONTH); final NumberFormat nfDay = new DecimalFormat("00"); final SimpleDateFormat formatMonth = new SimpleDateFormat("MM.yyyy"); lblMonth.setText(formatMonth.format(getValue())); for (DayButton btn : days) { btn.setText(""); btn.setEnabled(false);/* w w w . ja v a 2s . co m*/ btn.setValue(null); btn.setSelected(false); } int startWeekday = DateUtils2.getWeekNumber(startOfMonth); for (int i = 0; i < daysOfMonth; i++) { DayButton btn = days.get(i + orderedWeekdays.indexOf(startWeekday)); btn.setText(nfDay.format(i + 1)); btn.value = DateUtils.setDays(startOfMonth, i + 1); btn.setEnabled(true); if (DateUtils.isSameDay(btn.value, this.value)) { btn.setSelected(true); } } }
From source file:co.com.soinsoftware.hotelero.view.JFRoomPayment.java
private Date getFinalDate(final Date initialDate, final int hour) { final LocalDate today = LocalDate.now(); LocalDateTime finalDateTime = null; if (DateUtils.isSameDay(initialDate, new Date())) { finalDateTime = today.plusDays(1).atTime(LocalTime.of(hour, 0)); } else {// w w w . ja va2 s.c om finalDateTime = today.atTime(LocalTime.of(hour, 0)); } final ZonedDateTime zdt = finalDateTime.atZone(ZoneId.systemDefault()); return Date.from(zdt.toInstant()); }
From source file:io.lavagna.service.EventRepositoryTest.java
@Test public void testGetUserActivity() { List<EventsCount> activity = eventRepository.getUserActivity(user.getId(), oneYearAgo); Assert.assertEquals(1, activity.size()); Assert.assertEquals(1, activity.get(0).getCount()); Assert.assertTrue(DateUtils.isSameDay(new Date(), new Date(activity.get(0).getDate()))); }
From source file:models.Milestone.java
public String until() { if (dueDate == null) { return null; }// w w w . j av a 2 s. co m Date now = JodaDateUtil.now(); if (DateUtils.isSameDay(now, dueDate)) { return Messages.get("common.time.today"); } else if (isOverDueDate()) { return Messages.get("common.time.overday", JodaDateUtil.localDaysBetween(dueDate, now)); } else { return Messages.get("common.time.leftday", JodaDateUtil.localDaysBetween(now, dueDate)); } }
From source file:gov.nih.nci.firebird.data.RevisedInvestigatorRegistrationTest.java
@Test public void testGetRevisionDate() throws Exception { RevisedInvestigatorRegistration revisedRegistration = new RevisedInvestigatorRegistration(); assertTrue(DateUtils.isSameDay(new Date(), revisedRegistration.getRevisionDate())); }
From source file:gov.nih.nci.firebird.data.AnnualRegistrationPersistenceTest.java
private void checkRetrievedRegistration(AnnualRegistration original, AnnualRegistration retrieved) { assertNotNull(retrieved);//from ww w . java 2 s . co m assertSamePersistentObjects(original.getConfiguration(), retrieved.getConfiguration()); assertSamePersistentObjects(original.getProfile(), retrieved.getProfile()); assertEquals(original.getStatus(), retrieved.getStatus()); assertEquals(original.getStatusDate(), retrieved.getStatusDate()); assertEquals(original.getAnnualRegistrationType(), retrieved.getAnnualRegistrationType()); assertTrue(DateUtils.isSameDay(original.getDueDate(), retrieved.getDueDate())); }
From source file:io.lavagna.service.EventRepositoryTest.java
@Test public void testGetUserActivityForProject() { List<EventsCount> activity = eventRepository.getUserActivityForProjects(user.getId(), oneYearAgo, Arrays.asList(project.getId())); Assert.assertEquals(1, activity.size()); Assert.assertEquals(1, activity.get(0).getCount()); Assert.assertTrue(DateUtils.isSameDay(new Date(), new Date(activity.get(0).getDate()))); }
From source file:com.iorga.webappwatcher.analyzer.model.session.DurationPerPrincipalStats.java
public List<DayStatistic> computeDayStatistics() throws ClassNotFoundException, IOException { compute();// w ww. j a v a2 s .co m if (dayStatistics == null && timeSlices != null) { dayStatistics = Lists.newLinkedList(); DayStatistic currentDayStatistic = null; for (final TimeSlice timeSlice : timeSlices) { if (currentDayStatistic == null || !DateUtils.isSameDay(currentDayStatistic.startDate, timeSlice.startDate)) { // New day statistic if there is no current day statistic // or if the currentDayStatistic is not the same day than the timeSlice we are, let's create a new day statistic currentDayStatistic = new DayStatistic(timeSlice.startDate); dayStatistics.add(currentDayStatistic); } // expand the day statistic to that timeSlice currentDayStatistic.endDate = timeSlice.endDate; // compute each value if the timeSlice contains a data if (timeSlice.durationsFor1click.getN() > 0) { currentDayStatistic.distinctUsers.addValue(timeSlice.statsPerPrincipal.size()); currentDayStatistic.numberOfRequests.addValue(timeSlice.durationsFor1click.getN()); currentDayStatistic.durationsFor1clickSum.addValue(timeSlice.durationsFor1click.getSum()); currentDayStatistic.durationsFor1clickMean.addValue(timeSlice.durationsFor1click.getMean()); currentDayStatistic.durationsFor1clickMedian .addValue(timeSlice.durationsFor1click.getPercentile(50)); currentDayStatistic.durationsFor1click90c .addValue(timeSlice.durationsFor1click.getPercentile(90)); currentDayStatistic.durationsFor1clickMin.addValue(timeSlice.durationsFor1click.getMin()); currentDayStatistic.durationsFor1clickMax.addValue(timeSlice.durationsFor1click.getMax()); } currentDayStatistic.principals.addAll(timeSlice.statsPerPrincipal.keySet()); } } return dayStatistics; }
From source file:com.sube.daos.mongodb.StatisticDaoTest.java
private void generateUsages() throws InvalidSubeCardException, InvalidProviderException { for (int i = 0; i < usagesSize; i++) { SubeCardUsage usage = new SubeCardUsage(); usage.setCard((SubeCard) getRandom(cards)); Date randomDate = DateUtils.round( DateUtils.round(DateUtils.round(getRandomDate(FROM, TO), Calendar.SECOND), Calendar.MINUTE), Calendar.HOUR);//from w w w.j a va 2 s . c o m usage.setDatetime(randomDate); if ((randomDate.after(TO_DIFF) || DateUtils.isSameDay(randomDate, TO_DIFF)) && (randomDate.before(TO) || DateUtils.isSameDay(randomDate, TO))) { Long count = usages1.get(randomDate); if (count != null) { count++; } else { count = Long.valueOf(1l); } usages1.put(randomDate, count); } else if ((randomDate.after(FROM) || DateUtils.isSameDay(randomDate, FROM)) && (randomDate.before(FROM_DIFF) || DateUtils.isSameDay(randomDate, FROM_DIFF))) { Long count = usages2.get(randomDate); if (count != null) { count++; } else { count = Long.valueOf(1l); } usages2.put(randomDate, count); } if (random.nextInt() % 2 == 0) { //Charge Money usage.setMoney((random.nextDouble() + 0.1d) * MONEY_LAMBDA); // 3.1 // max, // min // 0.1 usage.setPerformer((Provider) getRandom(cashierProviders)); cardUsagesDao.chargeMoney(usage); } else { //Charge Service usage.setMoney((random.nextDouble() + 0.1d) * -MONEY_LAMBDA); // -3.1 // min, // max // -0.1 usage.setPerformer((Provider) getRandom(serviceProviders)); cardUsagesDao.chargeService(usage); Long travelsCount = travels.get(usage.getCard()); if (travelsCount == null) { travelsCount = Long.valueOf(1l); } else { travelsCount++; } travels.put(usage.getCard(), travelsCount); } Double totalMoney = usages.get(usage.getPerformer()); if (totalMoney == null) { usages.put(usage.getPerformer(), Math.abs(usage.getMoney())); } else { totalMoney += Math.abs(usage.getMoney()); usages.put(usage.getPerformer(), totalMoney); } registerMoneyExpended(usage); } }
From source file:ca.uhn.fhir.model.primitive.BaseDateTimeDt.java
/** * Returns <code>true</code> if this object represents a date that is today's date * //from www.j av a 2 s. c o m * @throws NullPointerException * if {@link #getValue()} returns <code>null</code> */ public boolean isToday() { Validate.notNull(getValue(), getClass().getSimpleName() + " contains null value"); return DateUtils.isSameDay(new Date(), getValue()); }