@Override public int compare(Object aObj, Object bObj) { Date a = (Date) aObj; Date b = (Date) bObj; return a.compareTo(b); }
@Override public List<MutablePair<String, String>> getIntervals(String lowerBound, String upperBound, int numPartitions, TypeInfo typeInfo) { List<MutablePair<String, String>> intervals = new ArrayList<>(); Date dateLower = Date.valueOf(lowerBound); Date dateUpper = Date.valueOf(upperBound); double dateInterval = (dateUpper.getTime() - dateLower.getTime())/(double)numPartitions; Date splitDateLower, splitDateUpper; for (int i=0;i<numPartitions;i++) { splitDateLower = new Date(Math.round(dateLower.getTime() + dateInterval*i)); splitDateUpper = new Date(Math.round(dateLower.getTime() + dateInterval*(i+1))); if (splitDateLower.compareTo(splitDateUpper) < 0) { intervals.add(new MutablePair<String, String>(splitDateLower.toString(), splitDateUpper.toString())); } } return intervals; } }
@Override public int compareTo(Object lhs, Object rhs, PDataType rhsType) { if (rhsType == TIMESTAMP || rhsType == UNSIGNED_TIMESTAMP) { return ((Timestamp)lhs).compareTo((Timestamp)rhs); } int c = ((Date)rhs).compareTo((Date)lhs); if (c != 0) return c; return ((Timestamp)lhs).getNanos(); }
@Test public void testNegativeDateTime() { Date date1 = new Date(-1000); Date date2 = new Date(-2000); assertTrue(date1.compareTo(date2) > 0); byte[] b1 = PDate.INSTANCE.toBytes(date1); byte[] b2 = PDate.INSTANCE.toBytes(date2); assertTrue(Bytes.compareTo(b1, b2) > 0); }
@Test public void testNegativeDateTime() { Date date1 = new Date(-1000); Date date2 = new Date(-2000); assertTrue(date1.compareTo(date2) > 0); byte[] b1 = PDataType.DATE.toBytes(date1); byte[] b2 = PDataType.DATE.toBytes(date2); assertTrue(Bytes.compareTo(b1, b2) > 0); }
private int dateEqual(Object actual, Object expected) { if (actual instanceof Date && expected instanceof Date) { return ((Date) actual).compareTo((Date) expected); } return -1; }
public static int compareSqlDate(Object left, Object right) { java.sql.Date l = (java.sql.Date) left; java.sql.Date r = (java.sql.Date) right; return l.compareTo(r); }
protected int compareSecure(Value o, CompareMode mode) { ValueDate v = (ValueDate) o; int c = value.compareTo(v.value); return c == 0 ? 0 : (c < 0 ? -1 : 1); }
private int dateEqual(Object actual, Object expected) { if (actual instanceof Date && expected instanceof Date) { return ((Date) actual).compareTo((Date) expected); } return -1; }
public static int compareDate(Date a, Date b) { return a.compareTo(b); }
@Override public int compareTo(final EingangsrechnungDO o) { int r = this.datum.compareTo(o.datum); if (r != 0) { return -r; } String s1 = StringUtils.defaultString(this.kreditor); String s2 = StringUtils.defaultString(o.kreditor); r = s1.compareTo(s2); if (r != 0) { return -r; } s1 = StringUtils.defaultString(this.referenz); s2 = StringUtils.defaultString(o.referenz); return s1.compareTo(s2); }
/** * @see org.kuali.kfs.coa.service.AccountingPeriodService#compareAccountingPeriodsByDate(org.kuali.kfs.coa.businessobject.AccountingPeriod, * org.kuali.kfs.coa.businessobject.AccountingPeriod) */ public int compareAccountingPeriodsByDate(AccountingPeriod tweedleDee, AccountingPeriod tweedleDum) { // note the lack of defensive programming here. If you send a null accounting // period...then chances are, you deserve the NPE that you receive Date tweedleDeeClose = tweedleDee.getUniversityFiscalPeriodEndDate(); Date tweedleDumClose = tweedleDum.getUniversityFiscalPeriodEndDate(); return tweedleDeeClose.compareTo(tweedleDumClose); }
/** * Compares two origin entry groups, based on the dates of their creation * * @param c1 the first origin entry group to compare * @param c2 you can't really compare without two origin groups * @return 0 if the creation dates are equal, a negative number if c1's creation date is less * than c2's; a positive number otherwise * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(Object c1, Object c2) { OriginEntryGroup oeg1 = (OriginEntryGroup) c1; OriginEntryGroup oeg2 = (OriginEntryGroup) c2; return oeg2.getDate().compareTo(oeg1.getDate()); }
public int compare(AssetRetirementGlobalDetail o1, AssetRetirementGlobalDetail o2) { // sort descending based on retirement date return o2.getAssetRetirementGlobal().getRetirementDate().compareTo(o1.getAssetRetirementGlobal().getRetirementDate()); } };
/** * @see org.kuali.kfs.module.endow.batch.KemidFeeService#ChargeFeeToKemid(KemidFee, boolean) */ public boolean chargeFeeToKemid(FeeMethod feeMethod, KemidFee kemidFee) { boolean chargeFee = true; boolean corpusPercentToleranceGreaterThanZero = (feeMethod.getCorpusPctTolerance().isGreaterThan(new KualiDecimal("0")) ? true : false ); if (kemidFee.getFeeStartDate().compareTo(kemService.getCurrentDate()) <= 0) { if (ObjectUtils.isNull(kemidFee.getFeeEndDate()) || (kemidFee.getFeeEndDate().compareTo(kemService.getCurrentDate()) > 0)) { chargeFee = kemidCorpusValueService.canFeeBeChargedToKemid(kemidFee.getKemid(), feeMethod.getCorpusPctTolerance()); return chargeFee; } } return chargeFee; }
/** * This method returns true if the effective date is not a date in the past or today's date. * * @param taxRegionRate * @return */ protected boolean isValidEffectiveDate(TaxRegionRate taxRegionRate) { boolean success = true; if (taxRegionRate.getEffectiveDate() != null) { Date currentDate = SpringContext.getBean(DateTimeService.class).getCurrentDate(); int comparison = taxRegionRate.getEffectiveDate().compareTo(currentDate); if (comparison == 0 || comparison < 0) { GlobalVariables.getMessageMap().putError(KFSConstants.TaxRegionConstants.TAX_REGION_EFFECTIVE_DATE, KFSKeyConstants.ERROR_DOCUMENT_TAX_REGION_CANT_ADD_PAST_OR_CURRENT_DATE_FOR_TAX_DISTRICT); success = false; } } return success; }
public void assertTier() { LOG.info("Asserting Tier {}", tierNo); if (newStartDate != null) assertEquals(0, newStartDate.compareTo(getTier().getStartDate())); else assertEquals(0, initialStartDate.compareTo(getTier().getStartDate())); if (newEndDate != null) assertEquals(0, newEndDate.compareTo(getTier().getEndDate())); else assertEquals(0, initialEndDate.compareTo(getTier().getEndDate())); LOG.info("{} tomics sold on Tier {}", getTier().getTomicsSold(), tierNo); LOG.info("{} tomics should have been sold on Tier {}", tomicsSold, tierNo); if (tomicsSold != null) assertEquals(0, tomicsSold.compareTo(getTier().getTomicsSold())); if (mustBeFull) assertTrue(getTier().isFull()); else assertFalse(getTier().isFull()); if (newTomicsMax != null) assertEquals(0, newTomicsMax.compareTo(getTier().getTomicsMax())); else assertEquals(0, initialTomicsMax.compareTo(getTier().getTomicsMax())); }