private long now() { return clock.getCurrentDate().getTime(); } }
public CompositeHealthStatus(final Application application, final String documentation, Clock clock) { this.application = application; this.documentation = documentation; this.healthy = true; this.time = clock.getCurrentDate().getTime(); }
private long now() { return clock.getCurrentDate().getTime(); }
/** * Consult the clock to get the current date. * * @return the current date as per the clock set in #setClock, or new Date() if * no clock is set */ public Date getCurrentDate() { if (clock != null) return clock.getCurrentDate(); return new Date(); }
/** * Consult the clock to get the current date. * * @return the current date as per the clock set in #setClock, or new Date() if * no clock is set */ public Date getCurrentDate() { if (clock != null) return clock.getCurrentDate(); return new Date(); }
final long getCurrentTime() { return clock.getCurrentDate().getTime(); }
private Timestamp currentDate() { return new Timestamp(clock.getCurrentDate().getTime()); } }
private DateTime now() { return new DateTime(clock.getCurrentDate().getTime(), DateTimeZone.UTC); }
private int getDaysUntilDate(final Date date) { if (date == null) { return Integer.MAX_VALUE; } else { final double days = ((double) (date.getTime() - clock.getCurrentDate().getTime())) / TimeUnit.DAYS.toMillis(1); return (int)Math.floor(days); } }
@Override @Nonnull public List<ReindexRequest> transitionStatus(@Nonnull Iterable<ReindexRequest> requests, @Nonnull ReindexStatus newStatus) { final long transitionTime = clock.getCurrentDate().getTime(); final ImmutableList.Builder<ReindexRequest> transitionedRequestBuilder = ImmutableList.builder(); for (ReindexRequest request : requests) { transitionedRequestBuilder.add(transitionStatus(request, newStatus, transitionTime)); } return transitionedRequestBuilder.build(); }
public List<QueryLiteral> getValues(final QueryCreationContext queryCreationContext, final FunctionOperand operand, final TerminalClause terminalClause) { return Collections.singletonList(new QueryLiteral(operand, clock.getCurrentDate().getTime())); }
private Date parseDuration(final String str) { try { final long offset = parseDurationOffset(str); final Date currentDate = clock.getCurrentDate(); return new Date(currentDate.getTime() + offset); } catch (InvalidDurationException e) { return null; } catch (NumberFormatException ne) { return null; } }
private Boolean isLicenseThisOld(final LicenseDetails input, final Period period) { Date licensePurchaseDate = input.getJiraLicense().getPurchaseDate(); return new DateTime(licensePurchaseDate).withPeriodAdded(period, 1).isBefore(new DateTime(clock.getCurrentDate())); } }
private boolean hasExpired(final GenericValue gv) { final long maxAgeMS = rememberMeConfiguration.getCookieMaxAgeInSeconds() * 1000; final Timestamp createdTS = gv.getTimestamp(Columns.CREATED); //noinspection SimplifiableIfStatement if (createdTS == null) { // why would this ever be the case? worse things have happened at sea! return true; } final long howOld = createdTS.getTime() + maxAgeMS; final long now = clock.getCurrentDate().getTime(); return howOld < now; }
private LocalDate parseDuration(final String str) { try { final long offset = parseDurationOffset(str); final Date currentDate = clock.getCurrentDate(); return convertToLocalDate(currentDate.getTime() + offset); } catch (InvalidDurationException e) { return null; } catch (NumberFormatException ne) { return null; } }
@Override public void dismissFlagForUser(String flagKey, ApplicationUser user) { if (user == null || isBlank(flagKey)) { return; } JSONObject dismissals = getDismissalsForUser(user); try { dismissals.put(flagKey, clock.getCurrentDate().getTime()); setDismissalsForUser(user, dismissals); } catch (JSONException e) { log.debug("Exception occurred while trying to dismiss flag:", e); } }
private void writeFile() { long now = clock.getCurrentDate().getTime(); NodeSharedHomeStatus status = new NodeSharedHomeStatus(getNodeId(), now); sharedHomeNodeStatusWriter.writeNodeStatus(status); } }
@Override public void resetFlagDismissals(String flagKey) { JSONObject resets = getDismissalResets(); try { resets.put(flagKey, clock.getCurrentDate().getTime()); getPropertySet().setText(RESETS_KEY, resets.toString()); } catch (JSONException e) { log.debug("Exception occurred while trying reset flag dismissal:", e); } }
public RememberMeToken save(final RememberMeToken token) { final Timestamp now = new Timestamp(clock.getCurrentDate().getTime()); final Map<String, Object> values = MapBuilder.<String, Object>newBuilder(Columns.TOKEN, token.getRandomString()) .add(Columns.USERKEY, userKeyService.getKeyForUsername(token.getUserName())) .add(Columns.CREATED, now).toMap(); final GenericValue gv = delegator.createValue(TABLE, values); return releaseToken(gv); }
@Override public String format(DateTime dateTime, Locale locale) { final TimeZone userTimeZone = timeZoneInfoResolver.getUserTimeZone(new JiraServiceContextImpl(jiraAuthenticationContext.getUser())); final DateTime referenceDateTime = new DateTime(clock.getCurrentDate(), DateTimeZone.forTimeZone(userTimeZone)); final String dateI18nKey = RelativeFormatter.getDayI18nKey(dateTime, referenceDateTime); final boolean formatterRelative = applicationProperties.getOption(APKeys.JIRA_LF_DATE_RELATIVE); if (formatterRelative && (dateI18nKey != null)) { final String dateString = relativeDatesFormatter.format(dateTime, locale); return serviceProvider.getText(dateI18nKey, dateString); } return datesFormatter.format(dateTime, locale); }