当前位置: 首页>>代码示例>>Java>>正文


Java Timestamp.before方法代码示例

本文整理汇总了Java中java.sql.Timestamp.before方法的典型用法代码示例。如果您正苦于以下问题:Java Timestamp.before方法的具体用法?Java Timestamp.before怎么用?Java Timestamp.before使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.Timestamp的用法示例。


在下文中一共展示了Timestamp.before方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: accessAutorisation

import java.sql.Timestamp; //导入方法依赖的package包/类
/**
 * Method checking rights to access to /files
 * @param request REST obtained request - needed cookie "session"
 * @param response REST regived response
 */
void accessAutorisation(Request request, Response response){
    try{
        String sessionId = request.cookie("session");
        SessionData session = sessionDataDao.fetchBySessionId(sessionId).get(0);
        Timestamp time = new Timestamp(System.currentTimeMillis());
        Timestamp latestTime = new Timestamp(session.getLastAccessed().getTime()+60*1000);
        if(time.before(latestTime)){
            sessionDataDao.delete(session);
            sessionDataDao.insert(new SessionData(session.getSessionId(), session.getUserId(), time));
        }else {
            sessionDataDao.delete(session);
            response.status(401);
            throw new AuthorizationException();
        }
    }catch(Exception e) {
        response.status(401);
        throw new AuthorizationException();
    }
}
 
开发者ID:Ewastachow,项目名称:java-rest-server,代码行数:25,代码来源:UserController.java

示例2: getEarliest

import java.sql.Timestamp; //导入方法依赖的package包/类
public static PacketInfo getEarliest(LinkedHashSet<PacketInfo> packetInfos) {
    if ((packetInfos == null) || (packetInfos.isEmpty())) {
        throw new IllegalArgumentException("Cannot get earliest of null or empty PacketInfo set!");
    }
    PacketInfo earliest = null;
    Timestamp earliestTimestamp = null;
    for (PacketInfo current : packetInfos) {
        if (earliest == null) {
            earliest = current;
            earliestTimestamp = Timestamp.valueOf(current.get(PacketInfo.TIMESTAMP));
        } else {
            Timestamp currentTimestamp = Timestamp.valueOf(current.get(PacketInfo.TIMESTAMP));
            if (currentTimestamp.before(earliestTimestamp)) {
                earliest = current;
                earliestTimestamp = currentTimestamp;
            }
        }
    }
    return earliest;
}
 
开发者ID:rmcnew,项目名称:LiquidFortressPacketAnalyzer,代码行数:21,代码来源:PacketInfoUtils.java

示例3: 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);
}
 
开发者ID:TZClub,项目名称:OMIPlatform,代码行数:14,代码来源:GroupBuyingController.java

示例4: applyClosedIntervalCriterion

import java.sql.Timestamp; //导入方法依赖的package包/类
public static void applyClosedIntervalCriterion(Criteria intervalCriteria, Timestamp from, Timestamp to, org.hibernate.criterion.Criterion or) {
	if (intervalCriteria != null) {
		if (from != null && to != null) {
			if (to.before(from)) {
				throw new IllegalArgumentException(L10nUtil.getMessage(MessageCodes.INTERVAL_STOP_BEFORE_START, DefaultMessages.INTERVAL_STOP_BEFORE_START));
			}
			intervalCriteria.add(applyOr(
					Restrictions.or(
							Restrictions.or( // partial interval overlappings:
									Restrictions.and(Restrictions.ge("start", from), Restrictions.lt("start", to)),
									Restrictions.and(Restrictions.gt("stop", from), Restrictions.le("stop", to))
									),
									Restrictions.and(Restrictions.le("start", from), Restrictions.ge("stop", to))
							)
							, or));
		} else if (from != null && to == null) {
			intervalCriteria.add(applyOr(
					Restrictions.or( // partial interval overlappings:
							Restrictions.ge("start", from),
							Restrictions.gt("stop", from)
							)
							, or));
		} else if (from == null && to != null) {
			intervalCriteria.add(applyOr(Restrictions.lt("start", to), or));
		}
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:28,代码来源:CriteriaUtil.java

示例5: applyStartOpenIntervalCriterion

import java.sql.Timestamp; //导入方法依赖的package包/类
public static void applyStartOpenIntervalCriterion(Criteria intervalCriteria, Timestamp from, Timestamp to, org.hibernate.criterion.Criterion or) {
	if (intervalCriteria != null) {
		if (from != null && to != null) {
			if (to.before(from)) {
				throw new IllegalArgumentException(L10nUtil.getMessage(MessageCodes.INTERVAL_STOP_BEFORE_START, DefaultMessages.INTERVAL_STOP_BEFORE_START));
			}
			intervalCriteria.add(applyOr(
					Restrictions.or(
							Restrictions.or( // partial interval overlappings:
									Restrictions.and(Restrictions.ge("start", from), Restrictions.lt("start", to)),
									Restrictions.and(Restrictions.gt("stop", from), Restrictions.le("stop", to))
									),
									Restrictions.or( // total inclusions:
											Restrictions.and(Restrictions.le("start", from), Restrictions.ge("stop", to)),
											Restrictions.and(Restrictions.isNull("start"), Restrictions.ge("stop", to))
											)
							)
							, or));
		} else if (from != null && to == null) {
			intervalCriteria.add(applyOr(Restrictions.gt("stop", from), or));
		} else if (from == null && to != null) {
			intervalCriteria.add(applyOr(
					Restrictions.or(
							Restrictions.or( // partial interval overlappings:
									Restrictions.lt("start", to),
									Restrictions.le("stop", to)
									),
									Restrictions.and(Restrictions.isNull("start"), Restrictions.ge("stop", to))
							)
							, or));
		}
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:34,代码来源:CriteriaUtil.java

示例6: applyStopOpenIntervalCriterion

import java.sql.Timestamp; //导入方法依赖的package包/类
public static void applyStopOpenIntervalCriterion(Criteria intervalCriteria, Timestamp from, Timestamp to, org.hibernate.criterion.Criterion or) {
	if (intervalCriteria != null) {
		if (from != null && to != null) {
			if (to.before(from)) {
				throw new IllegalArgumentException(L10nUtil.getMessage(MessageCodes.INTERVAL_STOP_BEFORE_START, DefaultMessages.INTERVAL_STOP_BEFORE_START));
			}
			intervalCriteria.add(applyOr(
					Restrictions.or(
							Restrictions.or( // partial interval overlappings:
									Restrictions.and(Restrictions.ge("start", from), Restrictions.lt("start", to)),
									Restrictions.and(Restrictions.gt("stop", from), Restrictions.le("stop", to))
									),
									Restrictions.or( // total inclusions:
											Restrictions.and(Restrictions.le("start", from), Restrictions.ge("stop", to)),
											Restrictions.and(Restrictions.le("start", from), Restrictions.isNull("stop"))
											)
							)
							, or));
		} else if (from != null && to == null) {
			intervalCriteria.add(applyOr(
					Restrictions.or(
							Restrictions.or( // partial interval overlappings:
									Restrictions.ge("start", from),
									Restrictions.gt("stop", from)
									),
									Restrictions.and(Restrictions.le("start", from), Restrictions.isNull("stop"))
							)
							, or));
		} else if (from == null && to != null) {
			intervalCriteria.add(applyOr(Restrictions.lt("start", to), or));
		}
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:34,代码来源:CriteriaUtil.java

示例7: test17

import java.sql.Timestamp; //导入方法依赖的package包/类
@Test(expectedExceptions = NullPointerException.class)
public void test17() throws Exception {
    Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
    ts1.before(null);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TimestampTests.java

示例8: 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 + ")");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:53,代码来源:TimestampTest.java

示例9: setToDate

import java.sql.Timestamp; //导入方法依赖的package包/类
private void setToDate(Timestamp time)
{
    if (time.before(epoch)) setText("");
    else setText(dformat.format(time));
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:6,代码来源:MergeStatusTable.java

示例10: getTableCellRendererComponent

import java.sql.Timestamp; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col)
{
    setHorizontalAlignment(SwingConstants.CENTER);
    setFont(normal);
    setIcon(null);
    setText("");
    setToolTipText(null);
    if ((value == null) || !(value instanceof DecoratedMergeServer))
        return this;

    DecoratedMergeServer server = (DecoratedMergeServer)value;
    setColors(server.isActive() || server.isLocalHost(), false);
    if (server.isLocalHost())
        setBackground(mycolor);

    switch (col)
    {
        case 0:
            if (server.isLocalHost())
                setIcon(home);
            else if (server.isRemote())
                setIcon(servericon);
            else
                setIcon(group);
            break;
        case 1:
            if (server.getAddress().equals(""))
                setText(server.getHostname());
            else
                setText(server.getHostname()+"/"+server.getAddress());
            break;
        case 2:
            // set date but also mark colors if the last check has been too long (2x the server waittime)
            Timestamp last = server.getLastCheck();
            setToDate(last);
            if (!server.isLocalHost() && !last.before(epoch) && (System.currentTimeMillis() - last.getTime() > server.getWaitTime()*2000))
                setColors(server.isActive(), true);
            break;
        case 3:
            if (server.isActive())
                setToDate(server.getNextCheck());
            break;

        default: // a series hash column
            JSONObject seriesstatus = server.columns[col-BASE_COL_COUNT];
            if (seriesstatus == null) {
                return this;
            }

            String error = (String)seriesstatus.get("error");
            String progress = (String)seriesstatus.get("progress");
            String hash = (String)seriesstatus.get("totalhash");

            if (error != null) {
                setToolTipText(getToolTip(error, textLimit(hash, 12)));
                setText(error);
                setColors(server.isActive(), true);
            } else if (progress != null) {
                setText(progress);
            } else {
                if (isMismatchedWithLocal(table, col, hash))
                    setColors(server.isActive(), true);
                setText(textLimit(hash, 12));
                setFont(bold);
            }
            
            if (seriesstatus.containsKey("syncing"))
                setIcon(syncing);

            break;
    }
    return this;
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:75,代码来源:MergeStatusTable.java

示例11: validateTimestampAfterToday

import java.sql.Timestamp; //导入方法依赖的package包/类
public static void validateTimestampAfterToday(Timestamp timestamp) throws ValidationException {
    if(timestamp != null && timestamp.before(new Date())) {
        throw new ValidationException(PlanchesterMessages.VALIDATION_FAILDED);
    }
}
 
开发者ID:ITB15-S4-GroupD,项目名称:Planchester,代码行数:6,代码来源:Validator.java

示例12: applyStartOptionalIntervalCriterion

import java.sql.Timestamp; //导入方法依赖的package包/类
public static void applyStartOptionalIntervalCriterion(Criteria intervalCriteria, Timestamp from, Timestamp to, org.hibernate.criterion.Criterion or, boolean includeStop) {
	if (intervalCriteria != null) {
		if (from != null && to != null) {
			if (to.before(from)) {
				throw new IllegalArgumentException(L10nUtil.getMessage(MessageCodes.INTERVAL_STOP_BEFORE_START, DefaultMessages.INTERVAL_STOP_BEFORE_START));
			}
			intervalCriteria.add(applyOr(Restrictions.or(
					Restrictions.and(
							Restrictions.isNull("start"),
							Restrictions.and(
									includeStop ? Restrictions.ge("stop", from) : Restrictions.gt("stop", from),
											Restrictions.le("stop", to)
									)
							),
							Restrictions.and(
									Restrictions.isNotNull("start"),
									Restrictions.or(
											// partial interval overlappings:
											Restrictions.or(
													Restrictions.and(Restrictions.ge("start", from), includeStop ? Restrictions.le("start", to) : Restrictions.lt("start", to)),
													Restrictions.and(includeStop ? Restrictions.ge("stop", from) : Restrictions.gt("stop", from), Restrictions.le("stop", to))
													),
													// total inclusions:
													Restrictions.and(Restrictions.le("start", from), Restrictions.ge("stop", to))
											)
									)
					), or));
		} else if (from != null && to == null) {
			intervalCriteria.add(applyOr(Restrictions.or(
					Restrictions.and(
							Restrictions.isNull("start"),
							includeStop ? Restrictions.ge("stop", from) : Restrictions.gt("stop", from)
							),
							Restrictions.and(
									Restrictions.isNotNull("start"),
									Restrictions.or(
											Restrictions.ge("start", from),
											includeStop ? Restrictions.ge("stop", from) : Restrictions.gt("stop", from)
											)
									)
					), or));
		} else if (from == null && to != null) {
			intervalCriteria.add(applyOr(Restrictions.or(
					Restrictions.and(
							Restrictions.isNull("start"),
							Restrictions.le("stop", to)
							),
							Restrictions.and(
									Restrictions.isNotNull("start"),
									Restrictions.or(
											includeStop ? Restrictions.le("start", to) : Restrictions.lt("start", to),
													Restrictions.le("stop", to)
											)
									)
					), or));
		}
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:59,代码来源:CriteriaUtil.java

示例13: applyStopOptionalIntervalCriterion

import java.sql.Timestamp; //导入方法依赖的package包/类
public static void applyStopOptionalIntervalCriterion(Criteria intervalCriteria, Timestamp from, Timestamp to, org.hibernate.criterion.Criterion or, boolean includeStop) {
	if (intervalCriteria != null) {
		if (from != null && to != null) {
			if (to.before(from)) {
				throw new IllegalArgumentException(L10nUtil.getMessage(MessageCodes.INTERVAL_STOP_BEFORE_START, DefaultMessages.INTERVAL_STOP_BEFORE_START));
			}
			intervalCriteria.add(applyOr(Restrictions.or(
					Restrictions.and(
							Restrictions.isNull("stop"),
							Restrictions.and(
									Restrictions.ge("start", from),
									includeStop ? Restrictions.le("start", to) : Restrictions.lt("start", to)
									)
							),
							Restrictions.and(
									Restrictions.isNotNull("stop"),
									Restrictions.or(
											// partial interval overlappings:
											Restrictions.or(
													Restrictions.and(Restrictions.ge("start", from), includeStop ? Restrictions.le("start", to) : Restrictions.lt("start", to)),
													Restrictions.and(includeStop ? Restrictions.ge("stop", from) : Restrictions.gt("stop", from), Restrictions.le("stop", to))
													),
													// total inclusions:
													Restrictions.and(Restrictions.le("start", from), Restrictions.ge("stop", to))
											)
									)
					), or));
		} else if (from != null && to == null) {
			intervalCriteria.add(applyOr(Restrictions.or(
					Restrictions.and(
							Restrictions.isNull("stop"),
							Restrictions.ge("start", from)
							),
							Restrictions.and(
									Restrictions.isNotNull("stop"),
									Restrictions.or(
											Restrictions.ge("start", from),
											includeStop ? Restrictions.ge("stop", from) : Restrictions.gt("stop", from)
											)
									)
					), or));
		} else if (from == null && to != null) {
			intervalCriteria.add(applyOr(Restrictions.or(
					Restrictions.and(
							Restrictions.isNull("stop"),
							includeStop ? Restrictions.le("start", to) : Restrictions.lt("start", to)
							),
							Restrictions.and(
									Restrictions.isNotNull("stop"),
									Restrictions.or(
											includeStop ? Restrictions.le("start", to) : Restrictions.lt("start", to),
													Restrictions.le("stop", to)
											)
									)
					), or));
		}
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:59,代码来源:CriteriaUtil.java


注:本文中的java.sql.Timestamp.before方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。