當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。