public boolean isExpired() { if (getExpiresAt()==0) { return new Timestamp(System.currentTimeMillis()-getExpirationTime()).after(getCreated()); } else { return getExpiresAt() < System.currentTimeMillis(); } }
if (maxTimestampValue == null || colTimestampValue.after(maxTimestampValue)) { return colTimestampValue.toString();
assertTrue( "Update timestamp should have changed due to update", theEntity.updated.after( updated ) );
@Override public boolean isTimeout() { Timestamp now = new Timestamp(new Date().getTime()); return now.after(timeout); }
private void deleteExpiredCachedSessions() { Timestamp curr = getCurrentSqlDate(); sessions.entrySet().removeIf(entry -> curr.after(entry.getValue().getExpiredDate())); }
private void handle(APIValidateSessionMsg msg) { APIValidateSessionReply reply = new APIValidateSessionReply(); SessionInventory s = sessions.get(msg.getSessionUuid()); Timestamp current = dbf.getCurrentSqlTime(); boolean valid = true; if (s != null) { if (current.after(s.getExpiredDate())) { valid = false; logOutSession(s.getUuid()); } } else { SessionVO session = dbf.findByUuid(msg.getSessionUuid(), SessionVO.class); if (session != null && current.after(session.getExpiredDate())) { valid = false; logOutSession(session.getUuid()); } else if (session == null) { valid = false; } } reply.setValidSession(valid); bus.reply(msg, reply); }
@Test public void testDemonstrateSetNanosOnTimestampLosingMillis() { Timestamp ts1 = new Timestamp(120055); ts1.setNanos(60); Timestamp ts2 = new Timestamp(120100); ts2.setNanos(60); /* * This really should have been assertFalse() because we started with timestamps that * had different milliseconds 120055 and 120100. THe problem is that the timestamp's * constructor converts the milliseconds passed into seconds and assigns the left-over * milliseconds to the nanos part of the timestamp. If setNanos() is called after that * then the previous value of nanos gets overwritten resulting in loss of milliseconds. */ assertTrue(ts1.equals(ts2)); /* * The right way to deal with timestamps when you have both milliseconds and nanos to assign * is to use the DateUtil.getTimestamp(long millis, int nanos). */ ts1 = DateUtil.getTimestamp(120055, 60); ts2 = DateUtil.getTimestamp(120100, 60); assertFalse(ts1.equals(ts2)); assertTrue(ts2.after(ts1)); } }
@Test public void testDemonstrateSetNanosOnTimestampLosingMillis() { Timestamp ts1 = new Timestamp(120055); ts1.setNanos(60); Timestamp ts2 = new Timestamp(120100); ts2.setNanos(60); /* * This really should have been assertFalse() because we started with timestamps that * had different milliseconds 120055 and 120100. THe problem is that the timestamp's * constructor converts the milliseconds passed into seconds and assigns the left-over * milliseconds to the nanos part of the timestamp. If setNanos() is called after that * then the previous value of nanos gets overwritten resulting in loss of milliseconds. */ assertTrue(ts1.equals(ts2)); /* * The right way to deal with timestamps when you have both milliseconds and nanos to assign * is to use the DateUtil.getTimestamp(long millis, int nanos). */ ts1 = DateUtil.getTimestamp(120055, 60); ts2 = DateUtil.getTimestamp(120100, 60); assertFalse(ts1.equals(ts2)); assertTrue(ts2.after(ts1)); }
@Override protected void scripts() { SessionInventory s = getSession(uuid); if (s == null) { throw new OperationFailureException(err(IdentityErrors.INVALID_SESSION, "Session expired")); } Timestamp curr = getCurrentSqlDate(); if (curr.after(s.getExpiredDate())) { if (logger.isTraceEnabled()) { logger.debug(String.format("session expired[%s < %s] for account[uuid:%s]", curr, s.getExpiredDate(), s.getAccountUuid())); } logout(s.getUuid()); throw new OperationFailureException(err(IdentityErrors.INVALID_SESSION, "Session expired")); } } }.execute();
Timestamp alramTimeStamp = new Timestamp(calNow.getTimeInMillis()); Timestamp currentTimeStamp = new Timestamp(current_time); if (alramTimeStamp.after(currentTimeStamp)) { alarmManager.set(AlarmManager.RTC_WAKEUP, calNow.getTimeInMillis(), operation_morn); }
private void sessionCheck() { if (msg.getSession() == null) { throw new ApiMessageInterceptionException(err(IdentityErrors.INVALID_SESSION, "session of message[%s] is null", msg.getMessageName())); } if (msg.getSession().getUuid() == null) { throw new ApiMessageInterceptionException(err(IdentityErrors.INVALID_SESSION, "session uuid is null")); } SessionInventory session = sessions.get(msg.getSession().getUuid()); if (session == null) { SessionVO svo = dbf.findByUuid(msg.getSession().getUuid(), SessionVO.class); if (svo == null) { throw new ApiMessageInterceptionException(err(IdentityErrors.INVALID_SESSION, "Session expired")); } session = SessionInventory.valueOf(svo); sessions.put(session.getUuid(), session); } Timestamp curr = getCurrentSqlDate(); if (curr.after(session.getExpiredDate())) { logger.debug(String.format("session expired[%s < %s] for account[uuid:%s]", curr, session.getExpiredDate(), session.getAccountUuid())); logOutSession(session.getUuid()); throw new ApiMessageInterceptionException(err(IdentityErrors.INVALID_SESSION, "Session expired")); } this.session = session; } }
public boolean isUpdatedWithinDays(long days) { LocalDateTime daysAgo = LocalDateTime.now(ZoneId.of("UTC")).minusDays(days); return updatedAt.after(Timestamp.valueOf(daysAgo)); } }
public static boolean isDateAfterNow(Timestamp date) { Timestamp now = UtilDateTime.nowTimestamp(); if (date != null) { return date.after(now); } return false; } /** isTime returns true if string arguments hour, minute, and second form a valid time. */
/** * Returns if the {@link MethodIdentToSensorType} is active, meaning if the latest agent * registration included this instrumentation. * * @return True if the latest agent registration included the {@link MethodSensorTypeIdent} * instrumentation on {@link MethodIdent}. */ public boolean isActive() { return timestamp.after(methodIdent.getTimeStamp()) && timestamp.after(methodIdent.getPlatformIdent().getTimeStamp()); }
public boolean getReadAfterUpdate() { if (lastChecked == null) { return false; } return getLastChecked().after(gradebook.getLastUpdated()); }
/***********************************************************************/ public boolean isExtracted(AddDateAware object) throws IllegalArgumentException { ObjectUtils.assertInstance(AddDateAware.class, object); Timestamp addDate = ((AddDateAware) object).getAddDate(); return (addDate == null) ? false : !addDate.after(date); } }
@Override public Object resultToSqlArg(FieldType fieldType, DatabaseResults results, int columnPos) throws SQLException { Timestamp timestamp = results.getTimestamp(columnPos); if (timestamp == null || ZERO_TIMESTAMP.after(timestamp)) { return null; } else { return timestamp.getTime(); } }
public int compare(Object o1, Object o2) { Timestamp date1 = ((Note) o1).getNoteCreateDate(); Timestamp date2 = ((Note) o2).getNoteCreateDate(); if (date1.before(date2)) { return returnCode * -1; } else if (date1.after(date2)) { return returnCode; } else { return 0; } } });
public boolean checkTimestamp() { boolean result = !toTimestamp.equals(TIMESTAMP_UNDEFINED) && !fromTimestamp.equals(TIMESTAMP_UNDEFINED) && (this.toTimestamp.after(this.fromTimestamp)||this.toTimestamp.equals(this.fromTimestamp)); if (!result) { logger.log("fromTimestamp is after toTimestamp"); } return result; }
@Test public void testTimeStampDefault() throws Exception { Dao<TimeStampDefault, Object> dao = createDao(TimeStampDefault.class, true); TimeStampDefault foo = new TimeStampDefault(); Timestamp before = new Timestamp(System.currentTimeMillis()); Thread.sleep(1); assertEquals(1, dao.create(foo)); Thread.sleep(1); Timestamp after = new Timestamp(System.currentTimeMillis()); TimeStampDefault result = dao.queryForId(foo.id); assertTrue(result.timestamp.after(before)); assertTrue(result.timestamp.before(after)); }