Package org.joda.time.format

Examples of org.joda.time.format.PeriodFormatterBuilder$Composite


   */
  public DurationFormatter(Locale locale) {
    super();
    ResourceBundle bundle = ResourceBundle.getBundle(getClass().getName(),
        locale);
    PeriodFormatterBuilder builder = new PeriodFormatterBuilder();
    builder.appendDays();
    builder.appendSuffix(" " + bundle.getString("day"), " "
        + bundle.getString("days"));
    builder.appendSeparator(" ");
    builder.appendHours();
    builder.appendSuffix(" " + bundle.getString("hour"), " "
        + bundle.getString("hours"));
    builder.appendSeparator(" ");
    builder.appendMinutes();
    builder.appendSuffix(" " + bundle.getString("minute"), " "
        + bundle.getString("minutes"));
    this.formatter = builder.toFormatter().withLocale(locale);
  }
View Full Code Here


    public static boolean isValidCucumberJsonReport(String fileContent) {
        return fileContent.contains("\"keyword\":");
    }

    public static String formatDuration(Long duration) {
        PeriodFormatter formatter = new PeriodFormatterBuilder()
                .appendDays()
                .appendSuffix(" day", " days")
                .appendSeparator(" and ")
                .appendHours()
                .appendSuffix(" hour", " hours")
View Full Code Here

        return encryptionUtil.encrypt(value, seed);
    }

    private Period getSessionMaxAge() {
        String maxAge = environment.getRequiredProperty("auth.session.maxAge");
        PeriodFormatter format = new PeriodFormatterBuilder()
                .appendDays()
                .appendSuffix("d", "d")
                .printZeroRarelyFirst()
                .appendHours()
                .appendSuffix("h", "h")
View Full Code Here

    }

    @After
    public void testExit() {
        Duration duration = new Duration(testFunctionStart, new DateTime());
        PeriodFormatter periodFormatter = new PeriodFormatterBuilder()
                .appendLiteral("Finished "
                        .concat(getTestDescription()).concat(" in " ))
                .printZeroAlways()
                .appendMinutes()
                .appendSuffix(" minutes, ")
View Full Code Here

            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));
    }
View Full Code Here

*
* @author rup
*/
public class JodaTimeFormatter {
    public static String format(Period period) {
        PeriodFormatter output = new PeriodFormatterBuilder()
                .appendDays()
                .appendSuffix(" day", " days")
                .appendSeparator(", ")
                .appendHours()
                .appendSuffix(" hour", " hours")
View Full Code Here

        @Override
        public HtmlComponent createComponent(Object object, Class type) {
            StringBuilder result = new StringBuilder();
            if (object != null) {
                Duration duration = (Duration) object;
                PeriodFormatterBuilder periodFormatterBuilder = new PeriodFormatterBuilder();

                PeriodType periodType = PeriodType.forFields(getDurationFieldTypes());

                if (printZeroAlways) {
                    periodFormatterBuilder.printZeroAlways();
                }
                if (duration.getMillis() < 0) {
                    result.append("-");
                }

                MutablePeriod period = new MutablePeriod(Math.abs(duration.getMillis()), periodType);

                if (period.isSupported(DurationFieldType.years())) {
                    periodFormatterBuilder.appendYears().appendSuffix(
                            RenderUtils.getResourceString(enumerationBundle, CLASS_NAME + DurationFieldType.years().getName()
                                    + SHORT));
                }
                if (period.isSupported(DurationFieldType.months())) {
                    periodFormatterBuilder.appendMonths().appendSuffix(
                            RenderUtils.getResourceString(enumerationBundle, CLASS_NAME + DurationFieldType.months().getName()
                                    + SHORT));
                }
                if (period.isSupported(DurationFieldType.weeks())) {
                    periodFormatterBuilder.appendWeeks().appendSuffix(
                            RenderUtils.getResourceString(enumerationBundle, CLASS_NAME + DurationFieldType.weeks().getName()
                                    + SHORT));
                }
                if (period.isSupported(DurationFieldType.days())) {
                    periodFormatterBuilder.appendDays().appendSuffix(
                            RenderUtils.getResourceString(enumerationBundle, CLASS_NAME + DurationFieldType.days().getName()
                                    + SHORT));
                }
                if (period.isSupported(DurationFieldType.hours())) {
                    periodFormatterBuilder.appendHours().appendSuffix(
                            RenderUtils.getResourceString(enumerationBundle, CLASS_NAME + DurationFieldType.hours().getName()
                                    + SHORT));
                }
                if (period.isSupported(DurationFieldType.minutes())) {
                    periodFormatterBuilder
                            .minimumPrintedDigits(2)
                            .appendMinutes()
                            .appendSuffix(
                                    RenderUtils.getResourceString(enumerationBundle, CLASS_NAME
                                            + DurationFieldType.minutes().getName() + SHORT));
                }
                if (period.isSupported(DurationFieldType.seconds())) {
                    periodFormatterBuilder
                            .minimumPrintedDigits(2)
                            .appendSeconds()
                            .appendSuffix(
                                    RenderUtils.getResourceString(enumerationBundle, CLASS_NAME
                                            + DurationFieldType.seconds().getName() + SHORT));
                }
                if (period.isSupported(DurationFieldType.millis())) {
                    periodFormatterBuilder
                            .minimumPrintedDigits(2)
                            .appendMillis()
                            .appendSuffix(
                                    RenderUtils.getResourceString(enumerationBundle, CLASS_NAME
                                            + DurationFieldType.millis().getName() + SHORT));
                }
                result.append(periodFormatterBuilder.toFormatter().print(period));
            }
            return new HtmlText(result.toString());
        }
View Full Code Here

    if (value == null) {
      return null;
    }

    if (format == null) {
      format = new PeriodFormatterBuilder().printZeroRarelyLast().appendDays().appendSuffix("d").appendHours().appendSuffix("h")
          .appendMinutes().appendSuffix("m").appendSecondsWithOptionalMillis().appendSuffix("s").toFormatter();
    }

    ReadablePeriod p = null;
View Full Code Here

      ActionInvocation invocation = new ActionInvocation(action);


      DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm:ss");

      PeriodFormatter pFormatter= new PeriodFormatterBuilder()
      .printZeroAlways()
      .appendHours()
      .appendSeparator(":")
      .appendMinutes()
      .appendSeparator(":")
View Full Code Here

      Service service = device.findService(new UDAServiceId("AVTransport"));
      Action action = service.getAction("SnoozeAlarm");
      ActionInvocation invocation = new ActionInvocation(action);

      Period snoozePeriod = Period.minutes(minutes);
      PeriodFormatter pFormatter= new PeriodFormatterBuilder()
      .printZeroAlways()
      .appendHours()
      .appendSeparator(":")
      .appendMinutes()
      .appendSeparator(":")
View Full Code Here

TOP

Related Classes of org.joda.time.format.PeriodFormatterBuilder$Composite

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.