当前位置: 首页>>代码示例>>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;未经允许,请勿转载。