List of usage examples for org.joda.time Duration getStandardSeconds
public long getStandardSeconds()
From source file:com.facebook.stats.MultiWindowGauge.java
License:Apache License
private long calcRate(EventCounterIf<GaugeCounter> counter) { long value = counter.getValue(); ReadableDateTime end = counter.getEnd(); ReadableDateTime start = counter.getStart(); ReadableDateTime now = new DateTime(); Duration duration = now.isBefore(end) ? new Duration(start, now) : // so far new Duration(start, end); long secs = duration.getStandardSeconds(); return secs > 0 ? value / secs : value; }
From source file:com.facebook.stats.MultiWindowGauge.java
License:Apache License
@Override public long getAllTimeRate() { Duration sinceStart = new Duration(start, new DateTime()); if (sinceStart.getStandardSeconds() == 0) { return 0; }/*w ww .j av a 2s. c o m*/ return allTimeCounter.getValue() / sinceStart.getStandardSeconds(); }
From source file:com.facebook.stats.MultiWindowRate.java
License:Apache License
@Override public long getAllTimeRate() { Duration sinceStart = new Duration(start, getNow()); if (sinceStart.getStandardSeconds() == 0) { return 0; }//from w w w . j a va 2 s. co m return allTimeCounter.getValue() / sinceStart.getStandardSeconds(); }
From source file:com.floreantpos.swing.TimerWatch.java
License:Open Source License
@Override public void actionPerformed(ActionEvent e) { Interval interval = new Interval(date.getTime(), new Instant().getMillis()); Duration duration = interval.toDuration(); int timeOutValueYellow = 300; int timeOutValueRed = 600; if (AppConfig.getString("YellowTimeOut") != null) { timeOutValueYellow = Integer.parseInt(AppConfig.getString("YellowTimeOut")); //$NON-NLS-1$ }/* www .j a v a 2s.c om*/ if (AppConfig.getString("RedTimeOut") != null) { timeOutValueRed = Integer.parseInt(AppConfig.getString("RedTimeOut")); //$NON-NLS-1$ } if (timeOutValueYellow < duration.getStandardSeconds() && timeOutValueRed > duration.getStandardSeconds()) { backColor = Color.yellow; textColor = Color.black; } else if (timeOutValueRed < duration.getStandardSeconds()) { backColor = Color.red; textColor = Color.white; } else { backColor = Color.white; textColor = Color.black; } timerLabel.setText(duration.getStandardHours() + ":" + (duration.getStandardMinutes() % 60) + ":" //$NON-NLS-1$//$NON-NLS-2$ + (duration.getStandardSeconds() % 60)); }
From source file:com.google.cloud.pubsub.SubscriberConnection.java
License:Open Source License
public SubscriberConnection(String subscription, Credentials credentials, MessageReceiver receiver, Duration ackExpirationPadding, Channel channel, FlowController flowController, ScheduledExecutorService executor) { this.executor = executor; this.credentials = credentials; this.ackExpirationPadding = ackExpirationPadding; streamAckDeadlineSeconds = Math.max(INITIAL_ACK_DEADLINE_SECONDS, Ints.saturatedCast(ackExpirationPadding.getStandardSeconds())); this.receiver = receiver; this.subscription = subscription; this.flowController = flowController; outstandingAckHandlers = TreeMultimap.create(); pendingAcks = new HashSet<>(MAX_PER_REQUEST_CHANGES * 2); pendingNacks = new HashSet<>(MAX_PER_REQUEST_CHANGES * 2); // 601 buckets of 1s resolution from 0s to MAX_ACK_DEADLINE_SECONDS ackLatencyDistribution = new Distribution(MAX_ACK_DEADLINE_SECONDS + 1); this.channel = channel; alarmsLock = new ReentrantLock(); nextAckDeadlineExtensionAlarmTime = new Instant(Long.MAX_VALUE); messagesWaiter = new MessagesWaiter(); }
From source file:com.kopysoft.chronos.views.ClockFragments.Today.DatePairView.java
License:Open Source License
private void createUI(TodayAdapterPair adpter, Job thisJob) { //if(enableLog) Log.d(TAG, "Position: " + position); setOrientation(LinearLayout.VERTICAL); //retView.setOnItemLongClickListener(LongClickListener); header = View.inflate(getContext(), R.layout.today_view, null); DateTimeFormatter fmt = DateTimeFormat.forPattern("E, MMM d, yyyy"); ((TextView) header.findViewById(R.id.date)).setText(fmt.print(gDate)); if (!showPay()) { header.findViewById(R.id.moneyViewText).setVisibility(View.GONE); header.findViewById(R.id.moneyViewTotal).setVisibility(View.GONE); }// w w w . ja v a2s . co m ListView retView = (ListView) header.findViewById(R.id.listView); retView.setOnItemClickListener(listener); TextView tx = (TextView) header.findViewById(R.id.timeViewTotal); Duration dur = adapter.getTime(true); if (dur.getMillis() < 0 && gDate.toDateMidnight().isEqual(new DateMidnight())) { dur = dur.plus(DateTime.now().getMillis()); } int seconds = (int) dur.getStandardSeconds(); int minutes = (seconds / 60) % 60; int hours = (seconds / 60 / 60); String output = String.format("%d:%02d:%02d", hours, minutes, seconds % 60); if (dur.getMillis() >= 0) tx.setText(output); else tx.setText("--:--:--"); if (enableLog) Log.d(TAG, "job: " + thisJob); if (enableLog) Log.d(TAG, "seconds: " + seconds); if (enableLog) Log.d(TAG, "dur: " + dur.toString()); if (enableLog) Log.d(TAG, "pay rate: " + thisJob.getPayRate()); double money = adapter.getPayableTime(gDate.toDateMidnight().isEqual(new DateMidnight())); Currency moneyCurrency = Currency.getInstance(Locale.getDefault()); output = String.format("%s %.2f", moneyCurrency.getSymbol(), money); tx = (TextView) header.findViewById(R.id.moneyViewTotal); tx.setText(output); if (enableLog) Log.d(TAG, "pay amount: " + output); //header to the row addView(header); retView.setAdapter(adpter); retView.setSelection(0); //show button if (!gDate.toDateMidnight().isEqual(new DateMidnight())) { header.findViewById(R.id.clockInAndOutButton).setVisibility(View.GONE); } else { (header.findViewById(R.id.clockInAndOutButton)).setOnClickListener(buttonListener); if (dur.getMillis() < 0) { ((Button) header.findViewById(R.id.clockInAndOutButton)).setText("Clock Out"); } else { ((Button) header.findViewById(R.id.clockInAndOutButton)).setText("Clock In"); } } }
From source file:com.kopysoft.chronos.views.ClockFragments.Today.DatePairView.java
License:Open Source License
private void updateTime() { TextView tx = (TextView) header.findViewById(R.id.timeViewTotal); Duration dur = adapter.getTime(true); if (dur.getMillis() < 0 && gDate.toDateMidnight().isEqual(new DateMidnight())) { dur = dur.plus(DateTime.now().getMillis()); }/*from ww w .j a v a2s . c o m*/ int seconds = (int) dur.getStandardSeconds(); int minutes = (seconds / 60) % 60; int hours = (seconds / 60 / 60); String output = String.format("%d:%02d:%02d", hours, minutes, seconds % 60); tx.setText(output); double money = adapter.getPayableTime(true); Currency moneyCurrency = Currency.getInstance(Locale.getDefault()); output = String.format("%s %.2f", moneyCurrency.getSymbol(), money); tx = (TextView) header.findViewById(R.id.moneyViewTotal); tx.setText(output); if (enableLog) Log.d(TAG, "pay amount: " + output); }
From source file:com.linkedin.pinot.core.realtime.impl.kafka.KafkaHighLevelStreamProviderConfig.java
License:Apache License
protected long convertToMs(String timeStr) { long ms = -1; try {/*from ww w . j a va 2s . c om*/ ms = Long.valueOf(timeStr); } catch (NumberFormatException e1) { try { Period p = PERIOD_FORMATTER.parsePeriod(timeStr); Duration d = p.toStandardDuration(); ms = d.getStandardSeconds() * 1000L; } catch (Exception e2) { throw new RuntimeException("Invalid time spec '" + timeStr + "' (Valid examples: '3h', '4h30m')", e2); } } return ms; }
From source file:com.mastfrog.acteur.headers.DurationHeader.java
License:Open Source License
@Override public String toString(Duration value) { return value.getStandardSeconds() + ""; }
From source file:com.sandata.lab.wcf.lookup.impl.RestLookupTablesService.java
License:Open Source License
private boolean lastCacheUpdateTimeExpired(final SandataLogger logger) { boolean bResult = false; String method = logger.getMethodName(); logger.setMethodName("lastCacheUpdateTimeExpired"); LocalDateTime now = LocalDateTime.now(); Duration duration = new Duration(lastCacheUpdateTime.toDateTime(DateTimeZone.UTC), now.toDateTime(DateTimeZone.UTC)); long seconds = duration.getStandardSeconds(); long minutes = duration.getStandardMinutes(); logger.info(String.format("Last Cache Update: %s", TimeFormat.SecondsToString(seconds))); if (minutes >= updateCacheInterval) { bResult = true;/* w ww . j a va2 s .c o m*/ } logger.setMethodName(method); return bResult; }