List of usage examples for org.joda.time.format PeriodFormatterBuilder appendSeparator
public PeriodFormatterBuilder appendSeparator(String text)
From source file:org.jspresso.framework.util.format.DurationFormatter.java
License:Open Source License
/** * Constructs a new {@code DurationFormatter} instance. * * @param translationProvider//from ww w . j av a 2 s. c o m * the translation provider for duration labels. * @param locale * the locale the formatter must be constructed in. */ public DurationFormatter(ITranslationProvider translationProvider, Locale locale, boolean secondsAware, boolean millisecondsAware) { super(); PeriodFormatterBuilder builder = new PeriodFormatterBuilder(); builder.appendDays(); builder.appendSuffix(" " + translationProvider.getTranslation("day", locale), " " + translationProvider.getTranslation("days", locale)); builder.appendSeparator(" "); builder.appendHours(); builder.appendSuffix(" " + translationProvider.getTranslation("hour", locale), " " + translationProvider.getTranslation("hours", locale)); builder.appendSeparator(" "); builder.appendMinutes(); builder.appendSuffix(" " + translationProvider.getTranslation("minute", locale), " " + translationProvider.getTranslation("minutes", locale)); if (secondsAware) { builder.appendSeconds(); builder.appendSuffix(" " + translationProvider.getTranslation("second", locale), " " + translationProvider.getTranslation("seconds", locale)); } if (millisecondsAware) { builder.appendMillis(); builder.appendSuffix(" " + translationProvider.getTranslation("millisecond", locale), " " + translationProvider.getTranslation("milliseconds", locale)); } this.formatter = builder.toFormatter().withLocale(locale); }