Refine search
private static PeriodFormatter buildWordBased(Locale locale) { ResourceBundle b = ResourceBundle.getBundle(BUNDLE_NAME, locale); if (containsKey(b, "PeriodFormat.regex.separator")) { return buildRegExFormatter(b, locale); } else { return buildNonRegExFormatter(b, locale); } }
PeriodFormatter pf = FORMATTERS.get(locale); if (pf == null) { DynamicWordBased dynamic = new DynamicWordBased(buildWordBased(locale)); pf = new PeriodFormatter(dynamic, dynamic, locale, null); PeriodFormatter existing = FORMATTERS.putIfAbsent(locale, pf); if (existing != null) {
public static String format(long l) { if (l == HOUR) { return "hour"; } else if (l == MINUTE) { return "minute"; } else if (l == TEN_SECOND) { return "10seconds"; } else { return PeriodFormat.getDefault().print(new Period(l)); } } }
public String format(PeriodType type) { Period period = new Period(millis()); return PeriodFormat.getDefault().withParseType(type).print(period); }
/** * Returns the period in msecs */ public static long parsePeriod(String periodStr) { PeriodFormatter fmt = PeriodFormat.getDefault(); Period p = fmt.parsePeriod(periodStr); return p.toStandardDuration().getMillis(); }
private PeriodPrinter getPrinter(Locale locale) { if (locale != null && !locale.equals(iFormatter.getLocale())) { return wordBased(locale).getPrinter(); } return iFormatter.getPrinter(); }
/** * Gets the default formatter that outputs words in English. * <p> * This calls {@link #wordBased(Locale)} using a locale of {@code ENGLISH}. * * @return the formatter, not null */ public static PeriodFormatter getDefault() { return wordBased(Locale.ENGLISH); }
@Override public void onSuccess( String result ) { Period timeDiff = new Period( startTime, DateTime.now() ); log.info( "File stored with key: '" + result + "'. Upload finished in " + timeDiff.toString( PeriodFormat.getDefault() ) ); } };
@Override public String toString() { return "count:" + count + ", cost:" + cost + ", avgCost:" + (double) (cost.get()) / count.get() + ", duration:" + PeriodFormat.getDefault().print(new Period(duration)); }
public String format(PeriodType type) { Period period = new Period(millis()); return PeriodFormat.getDefault().withParseType(type).print(period); }
private PeriodPrinter getPrinter(Locale locale) { if (locale != null && !locale.equals(iFormatter.getLocale())) { return wordBased(locale).getPrinter(); } return iFormatter.getPrinter(); }
/** * Gets the default formatter that outputs words in English. * <p> * This calls {@link #wordBased(Locale)} using a locale of {@code ENGLISH}. * * @return the formatter, not null */ public static PeriodFormatter getDefault() { return wordBased(Locale.ENGLISH); }
/** * This method is invoked when a log record is successfully sent to Kinesis. * Though this is not too useful for production use cases, it provides a good * debugging tool while tweaking parameters for the appender. */ @Override public void onSuccess(PutRecordRequest request, PutRecordResult result) { successfulRequestCount++; if (logger.isDebugEnabled() && (successfulRequestCount + failedRequestCount) % 3000 == 0) { logger.debug("Appender (" + appenderName + ") made " + successfulRequestCount + " successful put requests out of total " + (successfulRequestCount + failedRequestCount) + " in " + PeriodFormat.getDefault().print(new Period(startTime, DateTime.now())) + " since start"); } } }
public String format(PeriodType type) { Period period = new Period(millis()); return PeriodFormat.getDefault().withParseType(type).print(period); }
private PeriodPrinter getPrinter(Locale locale) { if (locale != null && !locale.equals(iFormatter.getLocale())) { return wordBased(locale).getPrinter(); } return iFormatter.getPrinter(); }
/** * Returns a word based formatter for the JDK default locale. * <p> * This calls {@link #wordBased(Locale)} using the {@link Locale#getDefault() default locale}. * * @return the formatter, not null * @since 2.0 */ public static PeriodFormatter wordBased() { return wordBased(Locale.getDefault()); }
PeriodFormatter pf = FORMATTERS.get(locale); if (pf == null) { DynamicWordBased dynamic = new DynamicWordBased(buildWordBased(locale)); pf = new PeriodFormatter(dynamic, dynamic, locale, null); PeriodFormatter existing = FORMATTERS.putIfAbsent(locale, pf); if (existing != null) {
private static PeriodFormatter buildWordBased(Locale locale) { ResourceBundle b = ResourceBundle.getBundle(BUNDLE_NAME, locale); if (containsKey(b, "PeriodFormat.regex.separator")) { return buildRegExFormatter(b, locale); } else { return buildNonRegExFormatter(b, locale); } }