コード例 #1
0
 /**
  * Gets the very short {@link PeriodFormatter}.
  *
  * @param aContentLocale The content locale for which the formatter is requested. May not be
  *     <code>null</code>.
  * @return the formatter
  */
 @Nonnull
 public static PeriodFormatter getFormatterVeryShort(@Nonnull final Locale aContentLocale) {
   final String[] aVariants = {" ", ",", ", "};
   return new PeriodFormatterBuilder()
       .appendYears()
       .appendSuffix(EText.SHORT_YEAR.getDisplayText(aContentLocale))
       .appendSeparator(" ", " ", aVariants)
       .appendMonths()
       .appendSuffix(EText.SHORT_MONTH.getDisplayText(aContentLocale))
       .appendSeparator(" ", " ", aVariants)
       .appendWeeks()
       .appendSuffix(EText.SHORT_WEEK.getDisplayText(aContentLocale))
       .appendSeparator(" ", " ", aVariants)
       .appendDays()
       .appendSuffix(EText.SHORT_DAY.getDisplayText(aContentLocale))
       .appendSeparator(" ", " ", aVariants)
       .appendHours()
       .appendSuffix(EText.SHORT_HOUR.getDisplayText(aContentLocale))
       .appendSeparator(" ", " ", aVariants)
       .appendMinutes()
       .appendSuffix(EText.SHORT_MINUTE.getDisplayText(aContentLocale))
       .appendSeparator(" ", " ", aVariants)
       .appendSeconds()
       .appendSuffix(EText.SHORT_SECOND.getDisplayText(aContentLocale))
       .appendSeparator(" ", " ", aVariants)
       .appendMillis()
       .appendSuffix(EText.SHORT_MILLISECOND.getDisplayText(aContentLocale))
       .toFormatter();
 }
コード例 #2
0
 /**
  * Gets the short {@link PeriodFormatter}.
  *
  * @param aContentLocale The content locale for which the formatter is requested. May not be
  *     <code>null</code>.
  * @return the formatter
  */
 @Nonnull
 public static PeriodFormatter getFormatterShort(@Nonnull final Locale aContentLocale) {
   final String sSepFront = EText.LONG_SEPARATOR_FRONT.getDisplayText(aContentLocale);
   final String sSepFinal = EText.LONG_SEPARATOR_LAST.getDisplayText(aContentLocale);
   final String[] aVariants = _getSeparatorVariants(aContentLocale);
   return new PeriodFormatterBuilder()
       .appendYears()
       .appendSuffix(EText.SHORT_YEAR.getDisplayText(aContentLocale))
       .appendSeparator(sSepFront, sSepFinal, aVariants)
       .appendMonths()
       .appendSuffix(EText.SHORT_MONTH.getDisplayText(aContentLocale))
       .appendSeparator(sSepFront, sSepFinal, aVariants)
       .appendWeeks()
       .appendSuffix(EText.SHORT_WEEK.getDisplayText(aContentLocale))
       .appendSeparator(sSepFront, sSepFinal, aVariants)
       .appendDays()
       .appendSuffix(EText.SHORT_DAY.getDisplayText(aContentLocale))
       .appendSeparator(sSepFront, sSepFinal, aVariants)
       .appendHours()
       .appendSuffix(EText.SHORT_HOUR.getDisplayText(aContentLocale))
       .appendSeparator(sSepFront, sSepFinal, aVariants)
       .appendMinutes()
       .appendSuffix(EText.SHORT_MINUTE.getDisplayText(aContentLocale))
       .appendSeparator(sSepFront, sSepFinal, aVariants)
       .appendSeconds()
       .appendSuffix(EText.SHORT_SECOND.getDisplayText(aContentLocale))
       .appendSeparator(sSepFront, sSepFinal, aVariants)
       .appendMillis()
       .appendSuffix(EText.SHORT_MILLISECOND.getDisplayText(aContentLocale))
       .toFormatter();
 }