List of usage examples for java.sql Timestamp after
public boolean after(Timestamp ts)
From source file:net.niyonkuru.koodroid.ui.UsageFragment.java
private void saveUsageTimestamps(Cursor cursor) { if (!cursor.isNull(UsagesQuery.UPDATED)) { Timestamp new_timestamp = Timestamp.valueOf(cursor.getString(UsagesQuery.UPDATED)); Object old_timestamp = mDataUpdatedTime.getTag(); if (old_timestamp == null || new_timestamp.after((Timestamp) old_timestamp)) { mDataUpdatedTime.setTag(new_timestamp); }//from w w w. jav a 2 s. c o m } }
From source file:org.openmicroscopy.shoola.agents.util.finder.AdvancedFinder.java
/** * Converts the UI context into a context to search for. * /*from w ww .j a v a 2s. c o m*/ * @param ctx The value to convert. */ private void handleSearchContext(SearchContext ctx) { String query = ctx.getQuery(); UserNotifier un = FinderFactory.getRegistry().getUserNotifier(); Timestamp start = ctx.getStartTime(); Timestamp end = ctx.getEndTime(); if (start != null && end != null && start.after(end)) { un.notifyInfo(TITLE, "The selected time interval is not valid."); return; } if (StringUtils.isEmpty(query) && start == null && end == null) { un.notifyInfo(TITLE, "Please enter a term to search for " + "or a valid time interval."); return; } List<Integer> context = ctx.getContext(); if (context == null || context.size() == 0) { context = new ArrayList<Integer>(); context.add(SearchContext.CUSTOMIZED); } List<Integer> scope = new ArrayList<Integer>(context.size()); Iterator i = context.iterator(); Integer v; while (i.hasNext()) { v = convertScope((Integer) i.next()); if (v != null) scope.add(v); } List<Class<? extends DataObject>> types = new ArrayList<Class<? extends DataObject>>(); i = ctx.getType().iterator(); Class<? extends DataObject> k; while (i.hasNext()) { k = convertType((Integer) i.next()); if (k != null) types.add(k); } SearchParameters searchContext = new SearchParameters(scope, types, query); searchContext.setTimeInterval(start, end, ctx.getTimeType()); searchContext.setUserId(ctx.getSelectedOwner()); SecurityContext secCtx; if (ctx.getSelectedGroup() == GroupContext.ALL_GROUPS_ID) { secCtx = new SecurityContext(getUserDetails().getGroupId()); searchContext.setGroupId(SearchParameters.ALL_GROUPS_ID); } else { secCtx = new SecurityContext(ctx.getSelectedGroup()); searchContext.setGroupId(ctx.getSelectedGroup()); } loader = new AdvancedFinderLoader(this, secCtx, searchContext); loader.load(); state = Finder.SEARCH; setSearchEnabled(true); }
From source file:org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand.java
@Override protected void verifyPrecondition() throws CommandException, PreconditionException { if (!(coordJob.getStatus() == CoordinatorJobBean.Status.PREP || coordJob.getStatus() == CoordinatorJobBean.Status.RUNNING || coordJob.getStatus() == CoordinatorJobBean.Status.RUNNINGWITHERROR)) { throw new PreconditionException(ErrorCode.E1100, "CoordMaterializeTransitionXCommand for jobId=" + jobId + " job is not in PREP or RUNNING but in " + coordJob.getStatus()); }//from w w w.jav a 2 s . c o m if (coordJob.isDoneMaterialization()) { throw new PreconditionException(ErrorCode.E1100, "CoordMaterializeTransitionXCommand for jobId =" + jobId + " job is already materialized"); } if (coordJob.getNextMaterializedTimestamp() != null && coordJob.getNextMaterializedTimestamp().compareTo(coordJob.getEndTimestamp()) >= 0) { throw new PreconditionException(ErrorCode.E1100, "CoordMaterializeTransitionXCommand for jobId=" + jobId + " job is already materialized"); } Timestamp startTime = coordJob.getNextMaterializedTimestamp(); if (startTime == null) { startTime = coordJob.getStartTimestamp(); if (startTime.after(new Timestamp(System.currentTimeMillis() + lookAheadWindow * 1000))) { throw new PreconditionException(ErrorCode.E1100, "CoordMaterializeTransitionXCommand for jobId=" + jobId + " job's start time is not reached yet - nothing to materialize"); } } if (coordJob.getNextMaterializedTimestamp() != null && coordJob.getNextMaterializedTimestamp() .after(new Timestamp(System.currentTimeMillis() + lookAheadWindow * 1000))) { throw new PreconditionException(ErrorCode.E1100, "CoordMaterializeTransitionXCommand for jobId=" + jobId + " Request is for future time. Lookup time is " + new Timestamp(System.currentTimeMillis() + lookAheadWindow * 1000) + " mat time is " + coordJob.getNextMaterializedTimestamp()); } if (coordJob.getLastActionTime() != null && coordJob.getLastActionTime().compareTo(coordJob.getEndTime()) >= 0) { throw new PreconditionException(ErrorCode.E1100, "ENDED Coordinator materialization for jobId = " + jobId + ", all actions have been materialized from start time = " + coordJob.getStartTime() + " to end time = " + coordJob.getEndTime() + ", job status = " + coordJob.getStatusStr()); } if (coordJob.getLastActionTime() != null && coordJob.getLastActionTime().compareTo(endMatdTime) >= 0) { throw new PreconditionException(ErrorCode.E1100, "ENDED Coordinator materialization for jobId = " + jobId + ", action is *already* materialized for Materialization start time = " + startMatdTime + ", materialization end time = " + endMatdTime + ", job status = " + coordJob.getStatusStr()); } if (endMatdTime.after(coordJob.getEndTime())) { throw new PreconditionException(ErrorCode.E1100, "ENDED Coordinator materialization for jobId = " + jobId + " materialization end time = " + endMatdTime + " surpasses coordinator job's end time = " + coordJob.getEndTime() + " job status = " + coordJob.getStatusStr()); } if (coordJob.getPauseTime() != null && !startMatdTime.before(coordJob.getPauseTime())) { throw new PreconditionException(ErrorCode.E1100, "ENDED Coordinator materialization for jobId = " + jobId + ", materialization start time = " + startMatdTime + " is after or equal to coordinator job's pause time = " + coordJob.getPauseTime() + ", job status = " + coordJob.getStatusStr()); } }
From source file:org.openmicroscopy.shoola.util.ui.search.SearchComponent.java
/** Fires a property change to search. */ void search() {/*from w w w.j ava 2 s .c om*/ List<Integer> scope = uiDelegate.getScope(); SearchContext ctx; if (scope.contains(SearchContext.ID)) { // create search context with search by ID only ctx = new SearchContext(uiDelegate.getSome(), ArrayUtils.EMPTY_STRING_ARRAY, ArrayUtils.EMPTY_STRING_ARRAY, Collections.singletonList(SearchContext.ID)); } else { // Terms cannot be null String[] some = uiDelegate.getSome(); String[] must = uiDelegate.getMust(); String[] none = uiDelegate.getNone(); ctx = new SearchContext(some, must, none, scope); int index = uiDelegate.getSelectedDate(); Timestamp start, end; switch (index) { case SearchContext.RANGE: start = uiDelegate.getFromDate(); end = uiDelegate.getToDate(); if (start != null && end != null && start.after(end)) ctx.setTime(end, start); else ctx.setTime(start, end); break; default: ctx.setTime(index); } ctx.setOwnerSearchContext(uiDelegate.getOwnerSearchContext()); ctx.setAnnotatorSearchContext(uiDelegate.getAnnotatorSearchContext()); ctx.setOwners(uiDelegate.getOwners()); ctx.setGroups(uiDelegate.getSelectedGroups()); ctx.setAnnotators(uiDelegate.getAnnotators()); ctx.setCaseSensitive(uiDelegate.isCaseSensitive()); ctx.setAttachmentType(uiDelegate.getAttachment()); ctx.setTimeType(uiDelegate.getTimeIndex()); ctx.setExcludedOwners(uiDelegate.getExcludedOwners()); ctx.setExcludedAnnotators(uiDelegate.getExcludedAnnotators()); ctx.setGroups(uiDelegate.getSelectedGroups()); } ctx.setType(uiDelegate.getType()); ctx.setGroups(uiDelegate.getSelectedGroups()); firePropertyChange(SEARCH_PROPERTY, null, ctx); }
From source file:org.opentaps.common.util.UtilCommon.java
/** * Returns the latest of the two given <code>Timestamp</code>. * @param ts1 a <code>Timestamp</code> * @param ts2 another <code>Timestamp</code> * @return ts1 if it is after ts2, ts2 otherwise */// ww w . j av a2 s . c o m public static Timestamp laterOf(Timestamp ts1, Timestamp ts2) { if (ts1.after(ts2)) { return ts1; } else { return ts2; } }
From source file:ome.services.ThumbnailCtx.java
/** * Whether or not the thumbnail metadata for a given Pixels ID is dirty * (the RenderingDef has been updated since the Thumbnail was). * @param pixelsId Pixels ID to check for dirty metadata. * @return <code>true</code> if the metadata is dirty <code>false</code> * otherwise./*from w ww . j a va 2 s. c o m*/ */ public boolean dirtyMetadata(long pixelsId) { Timestamp metadataLastUpdated = pixelsIdMetadataLastModifiedTimeMap.get(pixelsId); Timestamp settingsLastUpdated = pixelsIdSettingsLastModifiedTimeMap.get(pixelsId); if (log.isDebugEnabled()) { log.debug("Thumb time: " + metadataLastUpdated); log.debug("Settings time: " + settingsLastUpdated); } return settingsLastUpdated.after(metadataLastUpdated); }
From source file:org.kuali.rice.edl.impl.components.NoteConfigComponent.java
/** * Method added for notes editing function. Called by retrieveNoteList method * @param allNotes/*from w ww . j a v a2 s.c o m*/ * @param sortOrder * @return */ private List sortNotes(List allNotes, String sortOrder) { final int returnCode = KewApiConstants.Sorting.SORT_SEQUENCE_DSC.equalsIgnoreCase(sortOrder) ? -1 : 1; try { Collections.sort(allNotes, new Comparator() { 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; } } }); } catch (Throwable e) { LOG.error(e.getMessage(), e); } return allNotes; }
From source file:se.crisp.codekvast.warehouse.file_import.ImportDAOImpl.java
@Override public boolean saveInvocation(Invocation invocation, ImportContext context) { long applicationId = context.getApplicationId(invocation.getLocalApplicationId()); long methodId = context.getMethodId(invocation.getLocalMethodId()); long jvmId = context.getJvmId(invocation.getLocalJvmId()); Timestamp invokedAt = new Timestamp(invocation.getInvokedAtMillis()); Timestamp oldInvokedAt = queryForTimestamp( "SELECT invokedAtMillis FROM invocations WHERE applicationId = ? AND methodId = ? AND jvmId = ? ", applicationId, methodId, jvmId); boolean databaseTouched = false; if (oldInvokedAt == null) { jdbcTemplate.update(//from www. ja v a2 s . co m "INSERT INTO invocations(applicationId, methodId, jvmId, invokedAtMillis, invocationCount, status) " + "VALUES(?, ?, ?, ?, ?, ?) ", applicationId, methodId, jvmId, invokedAt.getTime(), invocation.getInvocationCount(), invocation.getStatus().name()); log.trace("Inserted invocation {}:{}:{} {}", applicationId, methodId, jvmId, invokedAt); databaseTouched = true; } else if (invokedAt.after(oldInvokedAt)) { jdbcTemplate.update( "UPDATE invocations SET invokedAtMillis = ?, invocationCount = invocationCount + ?, status = ? " + "WHERE applicationId = ? AND methodId = ? AND jvmId = ? ", invokedAt.getTime(), invocation.getInvocationCount(), invocation.getStatus().name(), applicationId, methodId, jvmId); log.trace("Updated invocation {}:{}:{} {}", applicationId, methodId, jvmId, invokedAt); databaseTouched = true; } else if (oldInvokedAt.equals(invokedAt)) { log.trace("Ignoring invocation, same row exists in database"); } else { log.trace("Ignoring invocation, a newer row exists in database"); } return databaseTouched; }
From source file:org.wso2.bpmn.mysql.DBConnector.java
public void calculateValues() throws SQLException, IOException, ParseException { ResultSet resultSet = null;/*from w w w . j a v a 2s . c om*/ try { ConfigLoader configLoader = ConfigLoader.getInstance(); resultSet = statement .executeQuery("select START_TIME_, END_TIME_, DURATION_ FROM ACT_HI_PROCINST WHERE " + "PROC_DEF_ID_ " + "= '" + configLoader.getProcessDefID() + "' AND END_TIME_ IS NOT NULL ORDER BY START_TIME_ ASC"); StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append("INSTANCE_COUNT__ \t\t"); stringBuffer.append("START_TIME_ \t\t"); stringBuffer.append("END_TIME_ \t\t\t"); stringBuffer.append("DURATION_ \t"); int rowCount = 0; Long totalDuration = 0l; while (resultSet.next()) { Timestamp rowStartTime = resultSet.getTimestamp(1); Timestamp rowStopTime = resultSet.getTimestamp(2); Long duration = resultSet.getLong(3); if (initialStartTime == null) { initialStartTime = rowStartTime; Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(rowStartTime.getTime()); cal.add(Calendar.SECOND, configLoader.getInitialTruncatingTime()); leastCalculationTime = new Timestamp(cal.getTime().getTime()); } if (rowStartTime.before(leastCalculationTime) == true) { continue; } if (startTime == null) { startTime = rowStartTime; } if (stopTime == null) { stopTime = rowStopTime; } if (rowStopTime.after(stopTime)) { stopTime = rowStopTime; } totalDuration += duration; ++rowCount; String resultString = rowCount + "\t\t\t" + rowStartTime.toString() + "\t\t" + rowStopTime + "\t\t" + duration; stringBuffer.append("\n"); stringBuffer.append(resultString); } if (rowCount == 0) { System.out.println("Error : Row count not found : "); } double averageDuration = (double) totalDuration / rowCount; double tps = ((double) rowCount) / calculateTimeDifferenceInSeconds(); String resultValue = "\tstartTime: " + startTime + "\n" + "\tendTime: " + stopTime + "\n" + "\tTotal " + "duration: " + totalDuration + "\n" + "\tAverage duration: " + averageDuration + "\n" + "\tInstance count: " + rowCount + "\n" + "\tTPS: " + tps; stringBuffer.append("\n\n\n\n"); stringBuffer.append(resultValue); FileUtils.writeStringToFile(new File(configLoader.getFilePath()), stringBuffer.toString()); System.out.println("===================Completed Calculation========================"); System.out.println(resultValue); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { e.printStackTrace(); } } if (connection != null) { try { connection.close(); } catch (SQLException e) { e.printStackTrace(); } } if (statement != null) { try { statement.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
From source file:edu.umd.cs.marmoset.modelClasses.Project.java
public String checkOnTime(Timestamp ts) { if (!ts.after(getOntime())) return "on-time"; if (ts.after(getOntime()) && !ts.after(late)) return "late"; return "very late"; }