Пример #1
0
 @Override
 public String formatUnrounded(Duration duration) {
   long quantity = duration.getQuantity();
   StringBuilder result = new StringBuilder();
   result.append(quantity);
   return result.toString();
 }
Пример #2
0
    private String performDecoration(boolean past, boolean future, long n, String time) {
      // a bit cryptic, yet well-tested
      // consider http://translate.sourceforge.net/wiki/l10n/pluralforms
      int pluralIdx =
          (n % 10 == 1 && n % 100 != 11
              ? 0
              : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
      if (pluralIdx > slavicPluralForms) {
        // impossible happening
        throw new IllegalStateException(
            "Wrong plural index was calculated somehow for slavic language");
      }

      StringBuilder result = new StringBuilder();

      if (future) {
        result.append("через ");
      }

      result.append(time);
      result.append(' ');
      result.append(pluarls[pluralIdx]);

      if (past) {
        result.append(" тому");
      }

      return result.toString();
    }