本文整理汇总了Java中java.sql.Timestamp.after方法的典型用法代码示例。如果您正苦于以下问题:Java Timestamp.after方法的具体用法?Java Timestamp.after怎么用?Java Timestamp.after使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.Timestamp
的用法示例。
在下文中一共展示了Timestamp.after方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLatest
import java.sql.Timestamp; //导入方法依赖的package包/类
public static PacketInfo getLatest(LinkedHashSet<PacketInfo> packetInfos) {
if ((packetInfos == null) || (packetInfos.isEmpty())) {
throw new IllegalArgumentException("Cannot get latest of null or empty PacketInfo set!");
}
PacketInfo latest = null;
Timestamp latestTimestamp = null;
for (PacketInfo current : packetInfos) {
if (latest == null) {
latest = current;
latestTimestamp = Timestamp.valueOf(current.get(PacketInfo.TIMESTAMP));
} else {
Timestamp currentTimestamp = Timestamp.valueOf(current.get(PacketInfo.TIMESTAMP));
if (currentTimestamp.after(latestTimestamp)) {
latest = current;
latestTimestamp = currentTimestamp;
}
}
}
return latest;
}
示例2: addGroupBuy
import java.sql.Timestamp; //导入方法依赖的package包/类
@PutMapping
public void addGroupBuy(@RequestBody Shopgroupbuy shopgroupbuy){
System.out.println(shopgroupbuy.getGpprice());
Timestamp ts = new Timestamp(System.currentTimeMillis());
if(ts.before(shopgroupbuy.getStarttime())){
shopgroupbuy.setIs_start(0);
}else if(ts.after(shopgroupbuy.getStarttime()) && ts.before(shopgroupbuy.getEndtime())){
shopgroupbuy.setIs_start(1);
}else if(ts.after(shopgroupbuy.getEndtime())){
shopgroupbuy.setIs_start(2);
}
this.shopgroupbuyService.insert(shopgroupbuy);
}
示例3: test22
import java.sql.Timestamp; //导入方法依赖的package包/类
@Test(expectedExceptions = NullPointerException.class)
public void test22() throws Exception {
Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
ts1.after(null);
}
示例4: compareTimestamps
import java.sql.Timestamp; //导入方法依赖的package包/类
/**
* Compares two Timestamps with the expected result.
*
* @param ts1 the first Timestamp
* @param ts2 the second Timestamp
* @param expect the expected relation between ts1 and ts2; 0 if
* ts1 equals to ts2, or 1 if ts1 is after ts2, or -1 if ts1 is
* before ts2.
*/
private void compareTimestamps(Timestamp ts1, Timestamp ts2, int expected) {
boolean expectedResult = expected > 0;
boolean result = ts1.after(ts2);
if (result != expectedResult) {
errln("ts1.after(ts2) returned " + result
+ ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
}
expectedResult = expected < 0;
result = ts1.before(ts2);
if (result != expectedResult) {
errln("ts1.before(ts2) returned " + result
+ ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
}
expectedResult = expected == 0;
result = ts1.equals(ts2);
if (result != expectedResult) {
errln("ts1.equals(ts2) returned " + result
+ ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
}
int x = ts1.compareTo(ts2);
int y = (x > 0) ? 1 : (x < 0) ? -1 : 0;
if (y != expected) {
errln("ts1.compareTo(ts2) returned " + x + ", expected "
+ relation(expected, "") + "0"
+ ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
}
long t1 = ts1.getTime();
long t2 = ts2.getTime();
int z = (t1 > t2) ? 1 : (t1 < t2) ? -1 : 0;
if (z == 0) {
int n1 = ts1.getNanos();
int n2 = ts2.getNanos();
z = (n1 > n2) ? 1 : (n1 < n2) ? -1 : 0;
}
if (z != expected) {
errln("ts1.getTime() " + relation(z, "==") + " ts2.getTime(), expected "
+ relation(expected, "==")
+ ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
}
}
示例5: validateTimestamp1BeforeTimestamp2
import java.sql.Timestamp; //导入方法依赖的package包/类
public static void validateTimestamp1BeforeTimestamp2(Timestamp timestamp1, Timestamp timestamp2) throws ValidationException {
if(timestamp1 != null && timestamp2 != null && timestamp1.after(timestamp2)) {
throw new ValidationException(PlanchesterMessages.VALIDATION_FAILDED);
}
}