當前位置: 首頁>>代碼示例>>Java>>正文


Java PeriodFormatterBuilder.appendDays方法代碼示例

本文整理匯總了Java中org.joda.time.format.PeriodFormatterBuilder.appendDays方法的典型用法代碼示例。如果您正苦於以下問題:Java PeriodFormatterBuilder.appendDays方法的具體用法?Java PeriodFormatterBuilder.appendDays怎麽用?Java PeriodFormatterBuilder.appendDays使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.joda.time.format.PeriodFormatterBuilder的用法示例。


在下文中一共展示了PeriodFormatterBuilder.appendDays方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: DurationFormatter

import org.joda.time.format.PeriodFormatterBuilder; //導入方法依賴的package包/類
/**
 * Constructs a new {@code DurationFormatter} instance.
 *
 * @param translationProvider
 *          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);
}
 
開發者ID:jspresso,項目名稱:jspresso-ce,代碼行數:39,代碼來源:DurationFormatter.java

示例2: cretePeriodFormatter

import org.joda.time.format.PeriodFormatterBuilder; //導入方法依賴的package包/類
private static PeriodFormatter cretePeriodFormatter(IntervalField startField, IntervalField endField)
{
    if (endField == null) {
        endField = startField;
    }

    List<PeriodParser> parsers = new ArrayList<>();

    PeriodFormatterBuilder builder = new PeriodFormatterBuilder();
    //CHECKSTYLE.OFF
    switch (startField) {
        case YEAR:
            builder.appendYears();
            parsers.add(builder.toParser());
            if (endField == IntervalField.YEAR) {
                break;
            }
            builder.appendLiteral("-");
        case MONTH:
            builder.appendMonths();
            parsers.add(builder.toParser());
            if (endField != IntervalField.MONTH) {
                throw new IllegalArgumentException("Invalid interval qualifier: " + startField + " to " + endField);
            }
            break;

        case DAY:
            builder.appendDays();
            parsers.add(builder.toParser());
            if (endField == IntervalField.DAY) {
                break;
            }
            builder.appendLiteral(" ");

        case HOUR:
            builder.appendHours();
            parsers.add(builder.toParser());
            if (endField == IntervalField.HOUR) {
                break;
            }
            builder.appendLiteral(":");

        case MINUTE:
            builder.appendMinutes();
            parsers.add(builder.toParser());
            if (endField == IntervalField.MINUTE) {
                break;
            }
            builder.appendLiteral(":");

        case SECOND:
            builder.appendSecondsWithOptionalMillis();
            parsers.add(builder.toParser());
    }
    //CHECKSTYLE.ON

    return new PeriodFormatter(builder.toPrinter(), new OrderedPeriodParser(parsers));
}
 
開發者ID:y-lan,項目名稱:presto,代碼行數:59,代碼來源:DateTimeUtils.java


注:本文中的org.joda.time.format.PeriodFormatterBuilder.appendDays方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。