) { return this.print(duration, width, false, Integer.MAX_VALUE);
return this.print(duration, width, false, Integer.MAX_VALUE);
/** * <p>Short-cut for {@code print(Duration.from(threeten))}. </p> * * @param threeten object representing a duration which might contain several units and quantities * @return formatted list output in normalized form * @throws IllegalArgumentException in case of conversion failures * @since 4.4 * @see #print(Duration) */ /*[deutsch] * <p>Abkürzung für {@code print(Duration.from(threeten))}. </p> * * @param threeten object representing a duration which might contain several units and quantities * @return formatted list output in normalized form * @throws IllegalArgumentException in case of conversion failures * @since 4.4 * @see #print(Duration) */ public String print(TemporalAmount threeten) { return this.print(Duration.from(threeten)); }
/** * <p>Short-cut for {@code print(Duration.from(threeten), width)}. </p> * * @param threeten object representing a duration which might contain several units and quantities * @param width text width (ABBREVIATED as synonym for SHORT) * @return formatted list output in normalized form * @throws IllegalArgumentException in case of conversion failures * @since 4.0 * @see #print(Duration, TextWidth) */ /*[deutsch] * <p>Abkürzung für {@code print(Duration.from(threeten), width)}. </p> * * @param threeten object representing a duration which might contain several units and quantities * @param width text width (ABBREVIATED as synonym for SHORT) * @return formatted list output in normalized form * @throws IllegalArgumentException in case of conversion failures * @since 4.0 * @see #print(Duration, TextWidth) */ public String print( TemporalAmount threeten, TextWidth width ) { return this.print(Duration.from(threeten), width); }
private String format( long amount, IsoUnit unit, boolean negative, TextWidth width ) { long value = amount; if (negative) { value = MathUtils.safeNegate(amount); } if (SUPPORTED_UNITS.contains(unit)) { if (unit.isCalendrical()) { CalendarUnit u = CalendarUnit.class.cast(unit); return this.print(value, u, width); } else { ClockUnit u = ClockUnit.class.cast(unit); if (u == NANOS) { if ((amount % MIO) == 0) { u = MILLIS; value = value / MIO; } else if ((amount % 1000) == 0) { u = MICROS; value = value / 1000; } } return this.print(value, u, width); } } throw new UnsupportedOperationException("Unknown unit: " + unit); }
) { return this.print(Duration.from(threeten), width, printZero, maxLength);
public void sendRealtimeAgentHealth(Account account, List<JvmAgentStatus> statusList) { VelocityContext ctx = new VelocityContext(); ctx.put("username", account.username()); List<Cluster> clusters = new ArrayList<>(); statusList.forEach(jas -> { Cluster c = new Cluster(); c.name = jas.getAnalysis().name(); List<Jvm> jvms = new ArrayList<>(); jas.getJvms().forEach(p -> { Jvm jvm = new Jvm(); jvm.name = p.getKey(); Duration dur = Duration.of(p.getValue(), ClockUnit.SECONDS).with(Duration.STD_CLOCK_PERIOD); jvm.period = PrettyTime.of(Locale.ENGLISH).print(dur, TextWidth.ABBREVIATED); jvms.add(jvm); }); c.jvms = jvms; clusters.add(c); }); ctx.put("clusters", clusters); String template = config.readString(ConfigProperty.EMAIL_AGENT_HEALTH_TEMPLATE); StringWriter msg = new StringWriter((int) (template.length() * 1.5)); if (Velocity.evaluate(ctx, msg, account.username(), template)) { sendNotification(account, "Real-time Agent Health Status", msg.toString()); } else { LOG.info("Unable to generate velocity template for message."); } }