本文整理汇总了Java中org.joda.time.DateTime.isEqual方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.isEqual方法的具体用法?Java DateTime.isEqual怎么用?Java DateTime.isEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.DateTime
的用法示例。
在下文中一共展示了DateTime.isEqual方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: equivalentTo
import org.joda.time.DateTime; //导入方法依赖的package包/类
public static Matcher<String> equivalentTo(DateTime expected) {
return new TypeSafeMatcher<String>() {
@Override
public void describeTo(Description description) {
description.appendText(String.format(
"a date time matching: %s", expected.toString()));
}
@Override
protected boolean matchesSafely(String textRepresentation) {
//response representation might vary from request representation
DateTime actual = DateTime.parse(textRepresentation);
return expected.isEqual(actual);
}
};
}
示例2: isEqual
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Override
public boolean isEqual(Event record1, Event record2, Attribute attribute) {
if(record1.getDates().size()==0 && record2.getDates().size()==0)
return true;
else if(record1.getDates().size()==0 ^ record2.getDates().size()==0)
return false;
else {//compare all dates
for (DateTime r1Date : record1.getDates()) {
for (DateTime r2Date : record2.getDates()) {
if (r1Date.isEqual(r2Date)) {
return true;//record1.getDates().getYear() == record2.getDates().getYear();
}
}
}
return false;
}
}
示例3: dateBetweenSearch
import org.joda.time.DateTime; //导入方法依赖的package包/类
@Test
public void dateBetweenSearch() throws IOException, SqlParseException, SQLFeatureNotSupportedException {
DateTimeFormatter formatter = DateTimeFormat.forPattern(DATE_FORMAT);
DateTime dateLimit1 = new DateTime(2014, 8, 18, 0, 0, 0);
DateTime dateLimit2 = new DateTime(2014, 8, 21, 0, 0, 0);
SearchHits response = query(String.format("SELECT insert_time FROM %s/online WHERE insert_time BETWEEN '2014-08-18' AND '2014-08-21' LIMIT 3", TEST_INDEX));
SearchHit[] hits = response.getHits();
for(SearchHit hit : hits) {
Map<String, Object> source = hit.getSource();
DateTime insertTime = formatter.parseDateTime((String) source.get("insert_time"));
boolean isBetween =
(insertTime.isAfter(dateLimit1) || insertTime.isEqual(dateLimit1)) &&
(insertTime.isBefore(dateLimit2) || insertTime.isEqual(dateLimit2));
Assert.assertTrue("insert_time must be between 2014-08-18 and 2014-08-21", isBetween);
}
}
示例4: hasExpired
import org.joda.time.DateTime; //导入方法依赖的package包/类
private boolean hasExpired(DateTime partitionDateTime, DateTime expiryThreshold) {
return partitionDateTime.isEqual(expiryThreshold) || partitionDateTime.isBefore(expiryThreshold);
}