当前位置: 首页>>代码示例>>Java>>正文


Java PeriodFormatter.print方法代码示例

本文整理汇总了Java中org.joda.time.format.PeriodFormatter.print方法的典型用法代码示例。如果您正苦于以下问题:Java PeriodFormatter.print方法的具体用法?Java PeriodFormatter.print怎么用?Java PeriodFormatter.print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.joda.time.format.PeriodFormatter的用法示例。


在下文中一共展示了PeriodFormatter.print方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calculateAge

import org.joda.time.format.PeriodFormatter; //导入方法依赖的package包/类
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);
	}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:21,代码来源:TvMazeUtils.java

示例2: dateHelper

import org.joda.time.format.PeriodFormatter; //导入方法依赖的package包/类
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));
        }
    };
}
 
开发者ID:web-innovate,项目名称:bootstraped-multi-test-results-report,代码行数:20,代码来源:Helpers.java

示例3: formattedDuration

import org.joda.time.format.PeriodFormatter; //导入方法依赖的package包/类
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);
    }
 
开发者ID:eyedol,项目名称:birudo,代码行数:17,代码来源:AppUtil.java

示例4: periodHourMinBased

import org.joda.time.format.PeriodFormatter; //导入方法依赖的package包/类
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());
}
 
开发者ID:darrillaga,项目名称:togg,代码行数:20,代码来源:DateTimeFormatter.java

示例5: toAge

import org.joda.time.format.PeriodFormatter; //导入方法依赖的package包/类
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)));
}
 
开发者ID:h2oai,项目名称:h2o-3,代码行数:17,代码来源:PrettyPrint.java

示例6: success

import org.joda.time.format.PeriodFormatter; //导入方法依赖的package包/类
@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();
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:26,代码来源:ProgressImpl.java

示例7: getDiffFormatted

import org.joda.time.format.PeriodFormatter; //导入方法依赖的package包/类
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(" "));
}
 
开发者ID:BlackCraze,项目名称:GameResourceBot,代码行数:14,代码来源:PrintUtils.java

示例8: convertMillisecondToMinutesAndSecond

import org.joda.time.format.PeriodFormatter; //导入方法依赖的package包/类
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);
}
 
开发者ID:ehsunshine,项目名称:memory-game,代码行数:12,代码来源:ConvertUtil.java

示例9: getTimestamp

import org.joda.time.format.PeriodFormatter; //导入方法依赖的package包/类
public static String getTimestamp(long duration) {
	PeriodFormatter periodFormatter = new PeriodFormatterBuilder()
			.appendYears().appendSuffix("y ")
			.appendMonths().appendSuffix("m ")
			.appendWeeks().appendSuffix("w ")
			.appendDays().appendSuffix("d ")
			.appendHours().appendSuffix("h ")
			.appendMinutes().appendSuffix("m ")
			.appendSeconds().appendSuffix("s")
			.toFormatter();
	return periodFormatter.print(new Period(new Duration(duration)).normalizedStandard());
}
 
开发者ID:LXGaming,项目名称:DiscordBot,代码行数:13,代码来源:DiscordUtil.java

示例10: timeToString

import org.joda.time.format.PeriodFormatter; //导入方法依赖的package包/类
/**
 * Generic method to convert the milliseconds into the elapsed time string.
 * 
 * @param start Start timestamp.
 * @param finish End timestamp.
 * @return String representation of the elapsed time.
 */
public static String timeToString(long start, long finish) {

  Duration duration = new Duration(finish - start); // in milliseconds
  PeriodFormatter formatter = new PeriodFormatterBuilder().appendDays().appendSuffix("d")
      .appendHours().appendSuffix("h").appendMinutes().appendSuffix("m").appendSeconds()
      .appendSuffix("s").appendMillis().appendSuffix("ms").toFormatter();

  return formatter.print(duration.toPeriod());

}
 
开发者ID:jMotif,项目名称:SAX,代码行数:18,代码来源:SAXProcessor.java

示例11: getFormattedDuration

import org.joda.time.format.PeriodFormatter; //导入方法依赖的package包/类
private String getFormattedDuration(int seconds) {
    Period period = new Period(Seconds.seconds(seconds));

    PeriodFormatter periodFormatter = new PeriodFormatterBuilder()
            .printZeroAlways()
            .minimumPrintedDigits(2)
            .appendHours()
            .appendSeparator(":")
            .appendMinutes()
            .appendSeparator(":")
            .appendSeconds()
            .toFormatter();

    return periodFormatter.print(period.normalizedStandard());
}
 
开发者ID:mbStavola,项目名称:FriendCaster,代码行数:16,代码来源:FeedRecyclerAdapter.java

示例12: formatPeriod

import org.joda.time.format.PeriodFormatter; //导入方法依赖的package包/类
/**
 *
 * @param start
 *            Set the start date
 * @param end
 *            Set the end date
 * @return a formatted period
 */
public static String formatPeriod(Date start, Date end) {
 DateTime startDate = new DateTime(start);
 DateTime endDate = new DateTime(end);

 Period period = new Interval(startDate, endDate).toPeriod();
 PeriodFormatter formatter = new PeriodFormatterBuilder()
 .minimumPrintedDigits(2).appendHours().appendSeparator(":")
 .appendMinutes().appendSeparator(":").appendSeconds()
 .toFormatter();
 return formatter.print(period);
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:20,代码来源:Functions.java

示例13: calcTimeLaps

import org.joda.time.format.PeriodFormatter; //导入方法依赖的package包/类
private String calcTimeLaps(long msLeft) {
    Period period = new Period(msLeft);
    PeriodFormatter daysHoursMinutes = new PeriodFormatterBuilder()
                                            .appendYears()
                                            .appendSuffix(" year", " years")
                                            .appendSeparator(", ")
                                            .appendMonths()
                                            .appendSuffix(" month", " months")
                                            .appendSeparator(", ")
                                            .appendWeeks()
                                            .appendSuffix(" week", " weeks")
                                            .appendSeparator(", ")
                                            .appendDays()
                                            .appendSuffix(" day", " days")
                                            .appendSeparator(" and ")
                                            .appendHours()
                                            .appendSuffix(" hour", " hours")
                                            .appendSeparator(", ")
                                            .appendMinutes()
                                            .appendSuffix(" minute", " minutes")
                                            .appendSeparator(", ")
                                            .appendSeconds()
                                            .appendSuffix(" second", " seconds")
                                            .appendSeparator(", ")
                                            .appendMillis()
                                            .appendSuffix(" millisecond", " milliseconds")
                                            .toFormatter();
    String ret = daysHoursMinutes.print(period.normalizedStandard());        
    return ret;
}
 
开发者ID:TungstenX,项目名称:EncDecZip,代码行数:31,代码来源:EncDecZip.java

示例14: toString

import org.joda.time.format.PeriodFormatter; //导入方法依赖的package包/类
@Override
public String toString() {
	PeriodFormatter formatter = new PeriodFormatterBuilder().appendHours().appendSuffix(":").appendMinutes()
			.appendSuffix(":").appendSeconds().appendSuffix(".").appendMillis().toFormatter();

	return this.modelName + " duration: " + formatter.print(this.getDuration().toPeriod());
}
 
开发者ID:mikejr83,项目名称:TLMReaderLib,代码行数:8,代码来源:FlightDefinition.java

示例15: duration

import org.joda.time.format.PeriodFormatter; //导入方法依赖的package包/类
private static String duration(Duration flightDuration) {
	Period period = flightDuration.toPeriod();
	PeriodFormatter hms = new PeriodFormatterBuilder().appendHours().appendSeparator(":").printZeroAlways()
			.appendMinutes().appendSeparator(":").appendSecondsWithMillis().toFormatter();

	return hms.print(period);
}
 
开发者ID:mikejr83,项目名称:TLMReaderLib,代码行数:8,代码来源:App.java


注:本文中的org.joda.time.format.PeriodFormatter.print方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。