本文整理了Java中java.sql.Date.compareTo()
方法的一些代码示例,展示了Date.compareTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Date.compareTo()
方法的具体详情如下:
包路径:java.sql.Date
类名称:Date
方法名:compareTo
暂无
代码示例来源:origin: lealone/Lealone
@Override
public int compare(Object aObj, Object bObj) {
Date a = (Date) aObj;
Date b = (Date) bObj;
return a.compareTo(b);
}
代码示例来源:origin: apache/hive
@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;
}
}
代码示例来源:origin: forcedotcom/phoenix
@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();
}
代码示例来源:origin: apache/phoenix
@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);
}
代码示例来源:origin: forcedotcom/phoenix
@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);
}
代码示例来源:origin: com.teradata.tempto/tempto-core
private int dateEqual(Object actual, Object expected)
{
if (actual instanceof Date && expected instanceof Date) {
return ((Date) actual).compareTo((Date) expected);
}
return -1;
}
代码示例来源:origin: actiontech/dble
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);
}
代码示例来源:origin: com.sqlapp/sqlapp-core
@Override
public boolean hasNext() {
if (this.step>0){
return (next.compareTo(end)<0);
} else{
return (next.compareTo(end)>0);
}
}
代码示例来源:origin: com.h2database/com.springsource.org.h2
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);
}
代码示例来源:origin: prestodb/tempto
private int dateEqual(Object actual, Object expected)
{
if (actual instanceof Date && expected instanceof Date) {
return ((Date) actual).compareTo((Date) expected);
}
return -1;
}
代码示例来源:origin: com.alibaba.blink/flink-table-common
public static int compareDate(Date a, Date b) {
return a.compareTo(b);
}
代码示例来源:origin: com.sqlapp/sqlapp-core
@Override
public boolean hasNext() {
if (this.step.isPositive()){
return (next.compareTo(end)<0);
} else{
return (next.compareTo(end)>0);
}
}
代码示例来源:origin: micromata/projectforge
@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);
}
代码示例来源:origin: se.skltp.tak/tak-core
private boolean isAnropsbehorighetInfoValidAtDate(AnropsbehorighetInfo ai, Date date){
return date == null || (ai.getFromTidpunkt().compareTo(date)<=0 && ai.getTomTidpunkt().compareTo(date)>=0);
}
代码示例来源:origin: org.kuali.kfs/kfs-core
/**
* @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);
}
代码示例来源:origin: org.kuali.kfs/kfs-core
/**
* 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());
}
代码示例来源:origin: org.kuali.kfs/kfs-core
public int compare(AssetRetirementGlobalDetail o1, AssetRetirementGlobalDetail o2) {
// sort descending based on retirement date
return o2.getAssetRetirementGlobal().getRetirementDate().compareTo(o1.getAssetRetirementGlobal().getRetirementDate());
}
};
代码示例来源:origin: org.kuali.kfs/kfs-module-endow
/**
* @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;
}
代码示例来源:origin: org.kuali.kfs/kfs-core
/**
* 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;
}
代码示例来源:origin: ICOnator/ICOnator-backend
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()));
}
内容来源于网络,如有侵权,请联系作者删除!