java类org.joda.time.format.PeriodFormatter的实例源码

EchoUtils.java 文件源码 项目:Equella 阅读 20 收藏 0 点赞 0 评论 0
public static String formatDuration(long duration)
{
    // Using Joda Time
    DateTime now = new DateTime(); // Now
    DateTime plus = now.plus(new Duration(duration * 1000));

    // Define and calculate the interval of time
    Interval interval = new Interval(now.getMillis(), plus.getMillis());
    Period period = interval.toPeriod(PeriodType.time());

    // Define the period formatter for pretty printing
    String ampersand = " & ";
    PeriodFormatter pf = new PeriodFormatterBuilder().appendHours().appendSuffix(ds("hour"), ds("hours"))
        .appendSeparator(" ", ampersand).appendMinutes().appendSuffix(ds("minute"), ds("minutes"))
        .appendSeparator(ampersand).appendSeconds().appendSuffix(ds("second"), ds("seconds")).toFormatter();

    return pf.print(period).trim();
}
ConnectionAdapter.java 文件源码 项目:Fahrplan 阅读 23 收藏 0 点赞 0 评论 0
private String prettifyDuration(String duration) {
    PeriodFormatter formatter = new PeriodFormatterBuilder()
            .appendDays().appendSuffix("d")
            .appendHours().appendSuffix(":")
            .appendMinutes().appendSuffix(":")
            .appendSeconds().toFormatter();

    Period p = formatter.parsePeriod(duration);

    String day = context.getResources().getString(R.string.day_short);

    if(p.getDays() > 0) {
        return String.format("%d"+ day + " %dh %dm", p.getDays(), p.getHours(), p.getMinutes());
    } else if (p.getHours() > 0) {
        return String.format(Locale.getDefault(), "%dh %dm", p.getHours(), p.getMinutes());
    } else {
        return String.format(Locale.getDefault(), "%dm", p.getMinutes());
    }
}
TvMazeUtils.java 文件源码 项目:drftpd3 阅读 26 收藏 0 点赞 0 评论 0
private static String calculateAge(DateTime epDate) {

        Period period;
        if (epDate.isBefore(new DateTime())) {
            period = new Period(epDate, new DateTime());
        } else {
            period = new Period(new DateTime(), epDate);
        }

        PeriodFormatter formatter = new PeriodFormatterBuilder()
                .appendYears().appendSuffix("y")
                .appendMonths().appendSuffix("m")
                .appendWeeks().appendSuffix("w")
                .appendDays().appendSuffix("d ")
                .appendHours().appendSuffix("h")
                .appendMinutes().appendSuffix("m")
                .printZeroNever().toFormatter();

        return formatter.print(period);
    }
Helpers.java 文件源码 项目:bootstraped-multi-test-results-report 阅读 32 收藏 0 点赞 0 评论 0
private Helper<Long> dateHelper() {
    return new Helper<Long>() {
        public CharSequence apply(Long arg0, Options arg1) throws IOException {
            PeriodFormatter formatter = new PeriodFormatterBuilder()
                .appendDays()
                .appendSuffix(" d : ")
                .appendHours()
                .appendSuffix(" h : ")
                .appendMinutes()
                .appendSuffix(" m : ")
                .appendSeconds()
                .appendSuffix(" s : ")
                .appendMillis()
                .appendSuffix(" ms")
                .toFormatter();
            return formatter.print(new Period((arg0 * 1) / 1000000));
        }
    };
}
MRCompactorTimeBasedJobPropCreator.java 文件源码 项目:Gobblin 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Return true iff input folder time is between compaction.timebased.min.time.ago and
 * compaction.timebased.max.time.ago.
 */
private boolean folderWithinAllowedPeriod(Path inputFolder, DateTime folderTime) {
  DateTime currentTime = new DateTime(this.timeZone);
  PeriodFormatter periodFormatter = getPeriodFormatter();
  DateTime earliestAllowedFolderTime = getEarliestAllowedFolderTime(currentTime, periodFormatter);
  DateTime latestAllowedFolderTime = getLatestAllowedFolderTime(currentTime, periodFormatter);

  if (folderTime.isBefore(earliestAllowedFolderTime)) {
    LOG.info(String.format("Folder time for %s is %s, earlier than the earliest allowed folder time, %s. Skipping",
        inputFolder, folderTime, earliestAllowedFolderTime));
    return false;
  } else if (folderTime.isAfter(latestAllowedFolderTime)) {
    LOG.info(String.format("Folder time for %s is %s, later than the latest allowed folder time, %s. Skipping",
        inputFolder, folderTime, latestAllowedFolderTime));
    return false;
  } else {
    return true;
  }
}
DateTimeUtils.java 文件源码 项目:presto 阅读 22 收藏 0 点赞 0 评论 0
public static long parseYearMonthInterval(String value, IntervalField startField, Optional<IntervalField> endField)
{
    IntervalField end = endField.orElse(startField);

    if (startField == IntervalField.YEAR && end == IntervalField.MONTH) {
        PeriodFormatter periodFormatter = INTERVAL_YEAR_MONTH_FORMATTER;
        return parsePeriodMonths(value, periodFormatter, startField, end);
    }
    if (startField == IntervalField.YEAR && end == IntervalField.YEAR) {
        return parsePeriodMonths(value, INTERVAL_YEAR_FORMATTER, startField, end);
    }

    if (startField == IntervalField.MONTH && end == IntervalField.MONTH) {
        return parsePeriodMonths(value, INTERVAL_MONTH_FORMATTER, startField, end);
    }

    throw new IllegalArgumentException("Invalid year month interval qualifier: " + startField + " to " + end);
}
AppUtil.java 文件源码 项目:birudo 阅读 38 收藏 0 点赞 0 评论 0
public static String formattedDuration(long duration) {

        PeriodFormatter hoursMinutes = new PeriodFormatterBuilder()
                .appendHours()
                .appendSuffix(" hr", " hrs")
                .appendSeparator(" ")
                .appendMinutes()
                .appendSuffix(" min", " mins")
                .appendSeparator(" ")
                .appendSeconds()
                .appendSuffix(" sec", " secs")
                .toFormatter();
        Period p = new Period(duration);

        return hoursMinutes.print(p);
    }
TvMazeUtils.java 文件源码 项目:drftpd3 阅读 27 收藏 0 点赞 0 评论 0
private static String calculateAge(DateTime epDate) {

        Period period;
        if (epDate.isBefore(new DateTime())) {
            period = new Period(epDate, new DateTime());
        } else {
            period = new Period(new DateTime(), epDate);
        }

        PeriodFormatter formatter = new PeriodFormatterBuilder()
                .appendYears().appendSuffix("y")
                .appendMonths().appendSuffix("m")
                .appendWeeks().appendSuffix("w")
                .appendDays().appendSuffix("d ")
                .appendHours().appendSuffix("h")
                .appendMinutes().appendSuffix("m")
                .printZeroNever().toFormatter();

        return formatter.print(period);
    }
LocalGatewayConfig.java 文件源码 项目:hadoop-mini-clusters 阅读 20 收藏 0 点赞 0 评论 0
public long getGatewayDeploymentsBackupAgeLimit() {
    PeriodFormatter f = (new PeriodFormatterBuilder()).appendDays().toFormatter();
    String s = this.get("gateway.deployment.backup.ageLimit", "-1");

    long d;
    try {
        Period e = Period.parse(s, f);
        d = e.toStandardDuration().getMillis();
        if (d < 0L) {
            d = -1L;
        }
    } catch (Exception var6) {
        d = -1L;
    }

    return d;
}
DateTimeFormatter.java 文件源码 项目:togg 阅读 24 收藏 0 点赞 0 评论 0
public static String periodHourMinBased(long secDuration) {
    PeriodFormatterBuilder builder = new PeriodFormatterBuilder();
    PeriodFormatter formatter = null;
    String minutesAbbr = ToggApp.getApplication().getString(
            R.string.minutes_abbr);
    ;
    String hoursAbbr = ToggApp.getApplication().getString(
            R.string.hours_abbr);
    ;

    formatter = builder.printZeroAlways().minimumPrintedDigits(1)
            .appendHours().appendLiteral(" " + hoursAbbr + " ")
            .minimumPrintedDigits(2).appendMinutes()
            .appendLiteral(" " + minutesAbbr).toFormatter();

    Period period = new Period(secDuration * 1000);

    return formatter.print(period.normalizedStandard());
}
SocietiesModule.java 文件源码 项目:societies 阅读 21 收藏 0 点赞 0 评论 0
@Singleton
@Provides
public PeriodFormatter providePeriodFormatter(Dictionary<String> dictionary) {
    return new PeriodFormatterBuilder()
            .appendYears()
            .appendSuffix(" " + dictionary.getTranslation("year"), " " + dictionary.getTranslation("years"))
            .appendSeparator(" ")
            .appendMonths()
            .appendSuffix(" " + dictionary.getTranslation("month"), " " + dictionary.getTranslation("months"))
            .appendSeparator(" ")
            .appendDays()
            .appendSuffix(" " + dictionary.getTranslation("day"), " " + dictionary.getTranslation("days"))
            .appendSeparator(" ")
            .appendMinutes()
            .appendSuffix(" " + dictionary.getTranslation("minute"), " " + dictionary.getTranslation("minutes"))
            .appendSeparator(" ")
            .appendSeconds()
            .appendSuffix(" " + dictionary.getTranslation("second"), " " + dictionary.getTranslation("seconds"))
            .toFormatter();
}
SlackServerAdapter.java 文件源码 项目:TCSlackNotifierPlugin 阅读 22 收藏 0 点赞 0 评论 0
private void postFailureBuild(SRunningBuild build )
{
    String message = "";

    PeriodFormatter durationFormatter = new PeriodFormatterBuilder()
            .printZeroRarelyFirst()
            .appendHours()
            .appendSuffix(" hour", " hours")
            .appendSeparator(" ")
            .printZeroRarelyLast()
            .appendMinutes()
            .appendSuffix(" minute", " minutes")
            .appendSeparator(" and ")
            .appendSeconds()
            .appendSuffix(" second", " seconds")
            .toFormatter();

    Duration buildDuration = new Duration(1000*build.getDuration());

    message = String.format("Project '%s' build failed! ( %s )" , build.getFullName() , durationFormatter.print(buildDuration.toPeriod()));

    postToSlack(build, message, false);
}
SlackServerAdapter.java 文件源码 项目:TCSlackNotifierPlugin 阅读 25 收藏 0 点赞 0 评论 0
private void processSuccessfulBuild(SRunningBuild build) {

        String message = "";

        PeriodFormatter durationFormatter = new PeriodFormatterBuilder()
                    .printZeroRarelyFirst()
                    .appendHours()
                    .appendSuffix(" hour", " hours")
                    .appendSeparator(" ")
                    .printZeroRarelyLast()
                    .appendMinutes()
                    .appendSuffix(" minute", " minutes")
                    .appendSeparator(" and ")
                    .appendSeconds()
                    .appendSuffix(" second", " seconds")
                    .toFormatter();

        Duration buildDuration = new Duration(1000*build.getDuration());

        message = String.format("Project '%s' built successfully in %s." , build.getFullName() , durationFormatter.print(buildDuration.toPeriod()));

        postToSlack(build, message, true);
    }
TimeBasedSubDirDatasetsFinder.java 文件源码 项目:incubator-gobblin 阅读 21 收藏 0 点赞 0 评论 0
/**
 * Return true iff input folder time is between compaction.timebased.min.time.ago and
 * compaction.timebased.max.time.ago.
 */
protected boolean folderWithinAllowedPeriod(Path inputFolder, DateTime folderTime) {
  DateTime currentTime = new DateTime(this.timeZone);
  PeriodFormatter periodFormatter = getPeriodFormatter();
  DateTime earliestAllowedFolderTime = getEarliestAllowedFolderTime(currentTime, periodFormatter);
  DateTime latestAllowedFolderTime = getLatestAllowedFolderTime(currentTime, periodFormatter);

  if (folderTime.isBefore(earliestAllowedFolderTime)) {
    log.info(String.format("Folder time for %s is %s, earlier than the earliest allowed folder time, %s. Skipping",
        inputFolder, folderTime, earliestAllowedFolderTime));
    return false;
  } else if (folderTime.isAfter(latestAllowedFolderTime)) {
    log.info(String.format("Folder time for %s is %s, later than the latest allowed folder time, %s. Skipping",
        inputFolder, folderTime, latestAllowedFolderTime));
    return false;
  } else {
    return true;
  }
}
RecompactionConditionTest.java 文件源码 项目:incubator-gobblin 阅读 22 收藏 0 点赞 0 评论 0
@Test
public void testRecompactionConditionBasedOnDuration() {
  RecompactionConditionFactory factory = new RecompactionConditionBasedOnDuration.Factory();
  RecompactionCondition conditionBasedOnDuration = factory.createRecompactionCondition(dataset);
  DatasetHelper helper = mock (DatasetHelper.class);
  when(helper.getDataset()).thenReturn(dataset);
  PeriodFormatter periodFormatter = new PeriodFormatterBuilder().appendMonths().appendSuffix("m").appendDays().appendSuffix("d").appendHours()
      .appendSuffix("h").appendMinutes().appendSuffix("min").toFormatter();
  DateTime currentTime = getCurrentTime();

  Period period_A = periodFormatter.parsePeriod("11h59min");
  DateTime earliest_A = currentTime.minus(period_A);
  when(helper.getEarliestLateFileModificationTime()).thenReturn(Optional.of(earliest_A));
  when(helper.getCurrentTime()).thenReturn(currentTime);
  Assert.assertEquals(conditionBasedOnDuration.isRecompactionNeeded(helper), false);

  Period period_B = periodFormatter.parsePeriod("12h01min");
  DateTime earliest_B = currentTime.minus(period_B);
  when(helper.getEarliestLateFileModificationTime()).thenReturn(Optional.of(earliest_B));
  when(helper.getCurrentTime()).thenReturn(currentTime);
  Assert.assertEquals(conditionBasedOnDuration.isRecompactionNeeded(helper), true);
}
PrettyPrint.java 文件源码 项目:h2o-3 阅读 19 收藏 0 点赞 0 评论 0
public static String toAge(Date from, Date to) {
  if (from == null || to == null) return "N/A";
  final Period period = new Period(from.getTime(), to.getTime());
  DurationFieldType[] dtf = new ArrayList<DurationFieldType>() {{
    add(DurationFieldType.years()); add(DurationFieldType.months());
    add(DurationFieldType.days());
    if (period.getYears() == 0 && period.getMonths() == 0 && period.getDays() == 0) {
      add(DurationFieldType.hours());
      add(DurationFieldType.minutes());
    }

  }}.toArray(new DurationFieldType[0]);

  PeriodFormatter pf = PeriodFormat.getDefault();
  return pf.print(period.normalizedStandard(PeriodType.forFields(dtf)));
}
ZergDaoModule.java 文件源码 项目:agathon 阅读 20 收藏 0 点赞 0 评论 0
@Provides @Singleton
AsyncHttpClientConfig provideAsyncHttpClientConfig(
    @Named(ZERG_CONNECTION_TIMEOUT_PROPERTY) Duration connectionTimeout,
    @Named(ZERG_REQUEST_TIMEOUT_PROPERTY) Duration requestTimeout) {
  PeriodFormatter formatter = PeriodFormat.getDefault();
  log.info("Using connection timeout {} and request timeout {}",
      formatter.print(connectionTimeout.toPeriod()), formatter.print(requestTimeout.toPeriod()));
  return new AsyncHttpClientConfig.Builder()
      .setAllowPoolingConnection(true)
      .setConnectionTimeoutInMs(Ints.saturatedCast(connectionTimeout.getMillis()))
      .setRequestTimeoutInMs(Ints.saturatedCast(requestTimeout.getMillis()))
      .setFollowRedirects(true)
      .setMaximumNumberOfRedirects(3)
      .setMaxRequestRetry(1)
      .build();
}
JodaTimeTests.java 文件源码 项目:exportlibrary 阅读 24 收藏 0 点赞 0 评论 0
@Test
public void testDurations() {
    DateTime start = org.joda.time.DateTime.now(DateTimeZone.UTC);
    long timeout = 1000;
    try {
        Thread.sleep(timeout);
    } catch (InterruptedException ex) {
        Thread.currentThread().interrupt();
    }
    DateTime finish = org.joda.time.DateTime.now(DateTimeZone.UTC);
    Interval interval = new Interval(start, finish);
    Period toPeriod = interval.toPeriod();
    PeriodFormatter daysHoursMinutes = new PeriodFormatterBuilder()
            .appendDays()
            .appendSuffix(" day", " days")
            .appendSeparator(" and ")
            .appendMinutes()
            .appendSuffix(" minute", " minutes")
            .appendSeparator(" and ")
            .appendSeconds()
            .appendSuffix(" second", " seconds")
            .toFormatter();

    logger.info("[{}]", daysHoursMinutes.print(toPeriod));
}
ProgressImpl.java 文件源码 项目:molgenis 阅读 26 收藏 0 点赞 0 评论 0
@Override
public void success()
{
    jobExecution.setEndDate(Instant.now());
    jobExecution.setStatus(SUCCESS);
    jobExecution.setProgressInt(jobExecution.getProgressMax());
    Duration yourDuration = Duration.millis(timeRunning());
    Period period = yourDuration.toPeriod();
    PeriodFormatter periodFormatter = new PeriodFormatterBuilder().appendDays()
                                                                  .appendSuffix("d ")
                                                                  .appendHours()
                                                                  .appendSuffix("h ")
                                                                  .appendMinutes()
                                                                  .appendSuffix("m ")
                                                                  .appendSeconds()
                                                                  .appendSuffix("s ")
                                                                  .appendMillis()
                                                                  .appendSuffix("ms ")
                                                                  .toFormatter();
    String timeSpent = periodFormatter.print(period);
    JOB_EXECUTION_LOG.info("Execution successful. Time spent: {}", timeSpent);
    sendEmail(jobExecution.getSuccessEmail(), jobExecution.getType() + " job succeeded.", jobExecution.getLog());
    update();
    JobExecutionContext.unset();
}
StyledExcelSpreadsheet.java 文件源码 项目:fenixedu-commons 阅读 24 收藏 0 点赞 0 评论 0
public void addDuration(Duration value, int columnNumber) {
    HSSFRow currentRow = getRow();
    HSSFCell cell = currentRow.createCell(columnNumber);
    PeriodFormatter fmt =
            new PeriodFormatterBuilder().printZeroAlways().appendHours().appendSeparator(":").minimumPrintedDigits(2)
                    .appendMinutes().toFormatter();
    MutablePeriod valueFormatted = new MutablePeriod(value.getMillis(), PeriodType.time());
    if (value.toPeriod().getMinutes() < 0) {
        valueFormatted.setMinutes(-value.toPeriod().getMinutes());
        if (value.toPeriod().getHours() == 0) {
            fmt =
                    new PeriodFormatterBuilder().printZeroAlways().appendLiteral("-").appendHours().appendSeparator(":")
                            .minimumPrintedDigits(2).appendMinutes().toFormatter();
        }
    }
    cell.setCellValue(fmt.print(valueFormatted));
    cell.setCellStyle(getExcelStyle(excelStyle.getValueStyle(), wrapText));

}
HeaderUtil.java 文件源码 项目:spring-rest-server 阅读 22 收藏 0 点赞 0 评论 0
private Period getSessionMaxAge() {
    String maxAge = environment.getRequiredProperty("auth.session.maxAge");
    PeriodFormatter format = new PeriodFormatterBuilder()
            .appendDays()
            .appendSuffix("d", "d")
            .printZeroRarelyFirst()
            .appendHours()
            .appendSuffix("h", "h")
            .printZeroRarelyFirst()
            .appendMinutes()
            .appendSuffix("m", "m")
            .toFormatter();
    Period sessionMaxAge = format.parsePeriod(maxAge);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Session maxAge is: "+
                formatIfNotZero(sessionMaxAge.getDays(), "days", "day") +
                formatIfNotZero(sessionMaxAge.getHours(), "hours", "hour") +
                formatIfNotZero(sessionMaxAge.getMinutes(), "minutes", "minute")
        );
    }
    return sessionMaxAge;
}
DurationUtils.java 文件源码 项目:amberdb 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Converts the duration in the format of HH:MM:SS:ss to HH:MM:SS
 * @param periodHHMMSSmm
 * @return
 */
public static String convertDuration(final String periodHHMMSSmm){
    String newDuration = periodHHMMSSmm;
    PeriodFormatter hoursMinutesSecondsMilli = new PeriodFormatterBuilder()
        .appendHours()
        .appendSeparator(":")
        .appendMinutes()
        .appendSeparator(":")
        .appendSeconds()
        .appendSeparator(":")
        .appendMillis()
        .toFormatter();
    try{
        if (StringUtils.isNotBlank(periodHHMMSSmm)){
            Period period = hoursMinutesSecondsMilli.parsePeriod(periodHHMMSSmm);
            newDuration = String.format("%02d:%02d:%02d", period.getHours(), period.getMinutes(), period.getSeconds());
        }
    }catch(IllegalArgumentException e){
        log.error("Invalid duration format: " + periodHHMMSSmm);
    }
    return newDuration;
}
IntervalParser.java 文件源码 项目:grafana-vertx-datasource 阅读 25 收藏 0 点赞 0 评论 0
public long parseToLong(String interval) {

        for (PeriodFormatter f : ALL) {
            try {
                return f.parsePeriod(interval).toStandardDuration().getMillis();
            } catch (IllegalArgumentException e) {
                //ommit
            }
        }
        return DEFAULT;
    }
PrintUtils.java 文件源码 项目:GameResourceBot 阅读 25 收藏 0 点赞 0 评论 0
public static String getDiffFormatted(Date from, Date to) {
    Duration duration = new Duration(to.getTime() - from.getTime()); // in
                                                                     // milliseconds
    PeriodFormatter formatter = new PeriodFormatterBuilder().printZeroNever()//
            .appendWeeks().appendSuffix("w").appendSeparator(" ")//
            .appendDays().appendSuffix("d").appendSeparator(" ")//
            .appendHours().appendSuffix("h").appendSeparator(" ")//
            .appendMinutes().appendSuffix("m").appendSeparator(" ")//
            .appendSeconds().appendSuffix("s")//
            .toFormatter();
    String fullTimeAgo = formatter.print(duration.toPeriod(PeriodType.yearMonthDayTime()));
    return Arrays.stream(fullTimeAgo.split(" ")).limit(2).collect(Collectors.joining(" "));
}
DurationFormatter.java 文件源码 项目:hyperrail-for-android 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Format a duration (in seconds) as hh:mm
 *
 * @param duration The duration in seconds
 * @return The duration formatted as hh:mm string
 */
@SuppressLint("DefaultLocale")
public static String formatDuration(Period duration) {
    // to minutes
    PeriodFormatter hhmm = new PeriodFormatterBuilder()
            .printZeroAlways()
            .minimumPrintedDigits(2) // gives the '01'
            .appendHours()
            .appendSeparator(":")
            .appendMinutes()
            .toFormatter();
    return duration.toString(hhmm);
}
ConvertUtil.java 文件源码 项目:memory-game 阅读 26 收藏 0 点赞 0 评论 0
public static String convertMillisecondToMinutesAndSecond(long milliseconds) {
    Duration duration = new Duration(milliseconds);
    Period period = duration.toPeriod();
    PeriodFormatter minutesAndSeconds = new PeriodFormatterBuilder()
            .printZeroAlways()
            .appendMinutes()
            .appendSeparator(":")
            .appendSeconds()
            .toFormatter();
    return minutesAndSeconds.print(period);
}
OnlineTotalSearchTask.java 文件源码 项目:ThunderMusic 阅读 22 收藏 0 点赞 0 评论 0
private int convertTime(String time) {
    PeriodFormatter formatter = ISOPeriodFormat.standard();
    Period p = formatter.parsePeriod(time);
    Seconds s = p.toStandardSeconds();

    return s.getSeconds();
}
YoutubeSearch.java 文件源码 项目:ThunderMusic 阅读 23 收藏 0 点赞 0 评论 0
private int convertTime(String time) {
    PeriodFormatter formatter = ISOPeriodFormat.standard();
    Period p = formatter.parsePeriod(time);
    Seconds s = p.toStandardSeconds();

    return s.getSeconds();
}
IntervalParser.java 文件源码 项目:grafana-vertx-datasource 阅读 26 收藏 0 点赞 0 评论 0
public long parseToLong(String interval) {

        for (PeriodFormatter f : ALL) {
            try {
                return f.parsePeriod(interval).toStandardDuration().getMillis();
            } catch (IllegalArgumentException e) {
                //ommit
            }
        }
        return DEFAULT;
    }
MediathekShow.java 文件源码 项目:zapp 阅读 20 收藏 0 点赞 0 评论 0
public String getFormattedDuration() {
    int duration;
    try {
        duration = Integer.parseInt(this.duration);
    } catch (NumberFormatException e) {
        return "?";
    }

    Period period = Duration.standardSeconds(duration).toPeriod();
    PeriodFormatter formatter = (period.getHours() > 0) ? hourPeriodFormatter : secondsPeriodFormatter;
    return period.toString(formatter);
}


问题


面经


文章

微信
公众号

扫码关注公众号