public NSTimestamp now() { return new NSTimestamp(); }
/** * @return the change counter of this event. * Computed from the current time, and will increase every * ten seconds. * @see ERCalendarEvent#sequence() */ public int sequence() { return (int)(new NSTimestamp().getTime() / 10000); }
private NSTimestamp randomTimestamp() { return new NSTimestamp().timestampByAddingGregorianUnits(0, 0, 0, -randomInt(24 * 1000), 0, 0); }
public String timestamp() { return new NSTimestamp().toString(); } }
public void sendDeathNotificationEmail() { NSTimestamp currentTime = new NSTimestamp(); String currentDate = currentTime.toString(); long cutOffTime = _lastRegistration.getTime() + lifebeatCheckInterval(); String assumedToBeDead = ""; if (currentTime.getTime() > cutOffTime) { long secondsDifference = (currentTime.getTime() - _lastRegistration.getTime()) / 1000; assumedToBeDead = "The app did not respond for " + secondsDifference + " seconds " + "which is greater than the allowed threshold of " + lifebeatCheckInterval() + " seconds " + "The app's current state was: " + stateArray[state] + ".\n" + assumedToBeDead + "The last successful communication occurred at: " + _lastRegistration.toString() + ". " + "This may be the result of a crash or an intentional shutdown from outside of wotaskd";
return; NSTimestamp currentTime = new NSTimestamp(System.currentTimeMillis(), java.util.TimeZone.getDefault()); TimeZone currentTimeZone = currentTime.timeZone(); int currentYear = currentTime.yearOfCommonEra(); int currentMonth = currentTime.monthOfYear(); int currentDayOfMonth = currentTime.dayOfMonth(); // [1,31] int currentHourOfDay = currentTime.hourOfDay(); // [0,23] int currentDayOfWeek = currentTime.dayOfWeek(); // [0,6] == startTime += interval; setNextScheduledShutdown(new NSTimestamp(currentYear, currentMonth, currentDayOfMonth, startTime, 0, 0, currentTimeZone)); currentDayOfMonth++; setNextScheduledShutdown(new NSTimestamp(currentYear, currentMonth, currentDayOfMonth, startTime, 0, 0, currentTimeZone)); currentDayOfMonth += 7; setNextScheduledShutdown(new NSTimestamp(currentYear, currentMonth, currentDayOfMonth, startTime, 0, 0, currentTimeZone));
public long timestamp() { return lastModified().getTime(); }
public Object marshall(SerializerState state, Object p, Object o) throws MarshallException { try { long time; String tz; if (o instanceof NSTimestamp) { time = ((NSTimestamp) o).getTime(); tz = ((NSTimestamp) o).timeZone().getID(); } else { throw new MarshallException("cannot marshall date using class " + o.getClass()); } JSONObject obj = new JSONObject(); if (ser.getMarshallClassHints()) { obj.put("javaClass", o.getClass().getName()); } obj.put("time", time); obj.put("tz", tz); return obj; } catch (JSONException e) { throw new MarshallException("Failed to marshall NSTimestamp.", e); } }
/** * Returns a new value by adding a delta to it. * In case of a {@link NSTimestamp}, the delta will be seconds, * in case of a {@link java.lang.Number Number}, the delta is added as a double. * Otherwise, a conversion to a double is attempted and the delta is added afterwards. */ protected Object newWithDelta(Object val, double delta) { double v; if (val instanceof NSTimestamp) { NSTimestamp vts = (NSTimestamp)val; NSTimestamp nvts = vts.timestampByAddingGregorianUnits(0, 0, 0, 0, 0, (int)delta); return nvts; } else if (val instanceof Number) { v = DRValueConverter.converter().doubleForValue(val) + delta; return (Double.valueOf(v)); } v = DRValueConverter.converter().doubleForValue(val) + delta; return Double.toString(v); }
public double doubleForValue(Object v) { double scr = 0.0; if(v == null) { return 0.0; } else if (v instanceof String) { try { scr = Double.parseDouble((String)v); } catch(NumberFormatException e) { log.error("Not a number: {}", v); scr = 0.0; } } else if(v instanceof Number){ Number vv = (Number)v; scr = vv.doubleValue(); } else if (v instanceof NSTimestamp) { NSTimestamp vv = (NSTimestamp)v; scr = vv.getTime() / 1000.0; } else if(v == NSKeyValueCoding.NullValue) { scr = 0.0; } else { try { scr = Double.parseDouble(v.toString()); } catch(NumberFormatException ex) { log.error("Not a number: {}", v); scr = 0.0; } } return scr; }
private void addComments(Bug bug) { int maxComments = randomInt(20); int last = 0; for (int i = 0; i < maxComments; i++) { Comment comment = Comment.clazz.createAndInsertObject(ec); int hours = last + randomInt(48); comment.setDateSubmitted(bug.dateSubmitted().timestampByAddingGregorianUnits(0, 0, 0, hours, 0, 0)); comment.setOriginator(randomUser()); comment.setTextDescription(randomText(50)); last = hours; comment.setBug(bug); bug.addToComments(comment); comment.validateForSave(); } }
public void updateTimestampForEditingContext(NSNotification n) { NSTimestamp now=new NSTimestamp(); EOEditingContext editingContext = (EOEditingContext)n.object(); log.debug("Timestamp for {}: {}", editingContext, now); _datesPerEC.put(editingContext, now); } }
public void willAttemptToStart() { state = MObject.STARTING; long timeForStartup; Integer tfs = _application.timeForStartup(); if (tfs != null) { timeForStartup = tfs.intValue(); } else { timeForStartup = MInstance.TIME_FOR_STARTUP; } _finishStartingByDate = new NSTimestamp(new NSTimestamp().getTime() + (timeForStartup * 1000)); }
public EOFetchSpecification fetchSpecificationForRecentBugs() { EOFetchSpecification fs = newFetchSpecification( andQualifier( new EOKeyValueQualifier(Key.DATE_MODIFIED, EOQualifier.QualifierOperatorGreaterThan, new NSTimestamp().timestampByAddingGregorianUnits(0, -1, 0, 0, 0, 0)), negateQualifier(qualifierForState(State.CLOSED)))); fs.setSortOrderings(new NSArray(new EOSortOrdering(Key.DATE_MODIFIED, EOSortOrdering.CompareDescending))); fs.setIsDeep(false); return fs; }
public String runningTime() { long aRunningTime = System.currentTimeMillis()-((NSTimestamp)statsDict.objectForKey("StartedAt")).getTime(); String aRunningTimeString = WOStatsPage._timeIntervalDescription(aRunningTime); return aRunningTimeString; }
private static void backupSiteConfig() { try { File sc = fileForSiteConfig(); if ( sc.exists() ) { NSTimestampFormatter formatter = new NSTimestampFormatter("%Y%m%d%H%M%S%F"); File renamedFile = new File(pathForSiteConfig() + "." + formatter.format(new NSTimestamp())); sc.renameTo(renamedFile); } } catch (NSForwardException ne) { log.error("Cannot backup file {}. Possible Permissions Problem.", pathForSiteConfig()); } }
public boolean isRunning_W() { long currentTime = (new NSTimestamp()).getTime(); long cutOffTime = _lastRegistration.getTime() + lifebeatCheckInterval(); long finishStartingByTime = _finishStartingByDate.getTime();
protected void resetSession(WOResponse response) { if(context().hasSession() || true) { session().terminate(); } String[] keys = cookieKeys(); for (int i = 0; i < keys.length; i++) { String key = keys[i]; WOCookie dummyCookie = new WOCookie(key, "dummy"); dummyCookie.setPath("/"); dummyCookie.setDomain(null); // Let the browser set the domain dummyCookie.setExpires(new NSTimestamp().timestampByAddingGregorianUnits(0, -2, 0, 0, 0, 0)); response.addCookie(dummyCookie); } }
aRunningTime = (aDate.getTime() - System.currentTimeMillis()) / 1000; } catch (java.text.ParseException ex) { aRunningTime = (float) 0.0;
@Override public void willUpdate() { super.willUpdate(); setLastModified(new NSTimestamp()); } }