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


Java DurationFormatUtils.formatDuration方法代码示例

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


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

示例1: getAge

import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
public static String getAge(long value) {
	long currentTime = (new Date()).getTime();
	long age = currentTime - value;
	String ageString = DurationFormatUtils.formatDuration(age, "d") + "d";
	if ("0d".equals(ageString)) {
		ageString = DurationFormatUtils.formatDuration(age, "H") + "h";
		if ("0h".equals(ageString)) {
			ageString = DurationFormatUtils.formatDuration(age, "m") + "m";
			if ("0m".equals(ageString)) {
				ageString = DurationFormatUtils.formatDuration(age, "s") + "s";
				if ("0s".equals(ageString)) {
					ageString = age + "ms";
				}
			}
		}
	}
	return ageString;
}
 
开发者ID:ibissource,项目名称:iaf,代码行数:19,代码来源:Misc.java

示例2: getValueAt

import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    Defense elem = entries.get(rowIndex);
    switch (columnIndex) {
        case 0:
            return elem.getSupporter();
        case 1:
            return elem.getTarget();
        case 2:
            return new Date(elem.getBestSendTime());
        case 3:
            return new Date(elem.getWorstSendTime());
        case 4:

            long sendTime = elem.getBestSendTime();
            if (sendTime < System.currentTimeMillis()) {//if best in past, take worst
                sendTime = elem.getWorstSendTime();
            }
            long t = sendTime - System.currentTimeMillis();
            t = (t <= 0) ? 0 : t;
            return DurationFormatUtils.formatDuration(t, "HHH:mm:ss.SSS", true);
        default:
            return elem.isTransferredToBrowser();
    }
}
 
开发者ID:Torridity,项目名称:dsworkbench,代码行数:26,代码来源:SupportsModel.java

示例3: getQueueFirstMessageAgeAsString

import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
protected static String getQueueFirstMessageAgeAsString(Session jSession,
		String queueName, long currentTime) {
	try {
		long age = getQueueFirstMessageAge(jSession, queueName, null,
				currentTime, false);
		if (age == -2) {
			return "??";
		} else if (age == -1) {
			return null;
		} else {
			return DurationFormatUtils.formatDuration(age, "ddd-HH:mm:ss");
		}
	} catch (JMSException e) {
		return "?";
	}
}
 
开发者ID:ibissource,项目名称:iaf,代码行数:17,代码来源:TibcoUtils.java

示例4: getTimeMonitorThread

import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
/**
 * Returns a thread which executes the provided command if the system clock moves forward or backwards by the
 * threshold specified.
 *
 * @param timeChangeCommand
 *            the command to run when system clock is changed
 * @param timeChangeThreshold
 *            the time difference in millisecs that the caller can adjust for, if the time changes by
 *            more than this amount, the time change command will be executed.
 * @param sleepInterval
 *            the amount of time the thread sleeps before it checks to see if system clock was changed
 *
 * @return the thread which the caller can decide to start
 */
public static Thread getTimeMonitorThread(final TimeChangeCommand timeChangeCommand, final long timeChangeThreshold,
        final long sleepInterval) {
    Runnable timeMonitorThread = new Runnable() {

        private long previousTime = new Date().getTime();

        @Override
        public void run() {
            while (true) {
                long currentTime = new Date().getTime();
                long timeDifference = currentTime - (this.previousTime + sleepInterval);
                if (timeDifference >= timeChangeThreshold || timeDifference <= -timeChangeThreshold) {
                    String timeDifferenceString = DurationFormatUtils.formatDuration(Math.abs(timeDifference),
                            "d 'Days' H 'Hours' m 'Minutes' s 'Seconds'");
                    log.warn(String.format(
                            "System Time change detected. Time shift: %s Current Time: %s  Previous Time: %s",
                            timeDifferenceString, new Date(currentTime), new Date(this.previousTime)));
                    timeChangeCommand.execute(timeDifference);
                }
                this.previousTime = currentTime;

                try {
                    Thread.sleep(sleepInterval);
                } catch (InterruptedException e) {
                    log.info("Time monitor thread interrupted. Ignoring...");
                }
            }
        }
    };

    return new Thread(timeMonitorThread, "Time-Monitor-Thread");
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:47,代码来源:ServerUtil.java

示例5: onTick

import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
@Override
public void onTick(long l) {
    if (l > 0) {
        mTimeStr = DurationFormatUtils.formatDuration(l, mTimePattern);
        //这是apache中的common的lang包中DurationFormatUtils类中的formatDuration,通过传入
        //一个时间格式就会自动将倒计时转换成相应的mTimePattern的样式(HH:mm:ss或dd天HH时mm分ss秒)
        setBackgroundSpan(mTimeStr);
    }
}
 
开发者ID:Alex-Jerry,项目名称:LLApp,代码行数:10,代码来源:MikyouCountDownTimer.java

示例6: updateTimestamp

import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
protected void updateTimestamp(long timestamp) {
	String formatDurationHMS = DurationFormatUtils.formatDuration(timestamp,
			(timestamp == 0 ? "--:--:--.---" : "HH:mm:ss.SSS"), true);
	timeLabel.setText(formatDurationHMS);
	String time = getReadableSimulationTime(timestamp);
	boolean isValidTime = time != null || (time != null && !time.isEmpty()) || timestamp != 0;
	timeIconLabel.setVisible(isValidTime);
	if (isValidTime) {
		timeLabel.setToolTipText("Simulation running since " + time);
		timeLabel.getParent().getParent().layout(); // layout all time-relevant components
	}
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:13,代码来源:SimulationView.java

示例7: getReadableSimulationTime

import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
protected String getReadableSimulationTime(long timestamp) {
	long days = TimeUnit.MILLISECONDS.toDays(timestamp);
	long hours = TimeUnit.MILLISECONDS.toHours(timestamp);
	long minutes = TimeUnit.MILLISECONDS.toMinutes(timestamp);
	long seconds = TimeUnit.MILLISECONDS.toSeconds(timestamp);
	return DurationFormatUtils
			.formatDuration(timestamp,
					(days > 0 ? "dd 'days '" : "") + (hours > 0 ? "HH 'hours '" : "")
							+ (minutes > 0 ? "mm 'minutes '" : "") + (seconds > 0 ? "ss 'seconds '" : ""),
					false);

}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:13,代码来源:SimulationView.java

示例8: getValueAt

import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    FarmInformation elem = (FarmInformation) FarmManager.getSingleton().getAllElements().get(rowIndex);
    switch (columnIndex) {
        case 0:
            return elem.getStatus();
        case 1:
            return elem.isResourcesFoundInLastReport();
        case 2:
            return new Date(elem.getLastReport());
        case 3:
            return elem.getVillage().getShortName();
        case 4:
            return elem.getWallLevel();
        case 5:
            return elem.getStorageStatus();
        case 6:
            long t = elem.getRuntimeInformation();
            t = (t <= 0) ? 0 : t;
            if (t == 0) {
                return "Keine Truppen unterwegs";
            }
            return DurationFormatUtils.formatDuration(t, "HH:mm:ss", true);
        case 7:
            return elem.getLastResult();
        default:
            return elem.getCorrectionFactor();
    }
}
 
开发者ID:Torridity,项目名称:dsworkbench,代码行数:30,代码来源:FarmTableModel.java

示例9: getUptimeLabel

import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
@Override
public Label getUptimeLabel(String wicketId) {
    long uptime = ContextHelper.get().getUptime();
    String uptimeStr = DurationFormatUtils.formatDuration(uptime, "d'd' H'h' m'm' s's'");
    Label uptimeLabel = new Label(wicketId, uptimeStr);
    //Only show uptime for admins
    if (!ContextHelper.get().getAuthorizationService().isAdmin()) {
        uptimeLabel.setVisible(false);
    }
    return uptimeLabel;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:12,代码来源:WicketAddonsImpl.java

示例10: getFormattedPeriod

import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
private String getFormattedPeriod(long seconds) {
	if (seconds > 0) {
		return DurationFormatUtils.formatDuration(seconds * 1000, "H:mm", true);
	}
	// TODO: Fix dates with no entries "0:00"
	return "";
}
 
开发者ID:turesheim,项目名称:eclipse-timekeeper,代码行数:8,代码来源:WorkWeekView.java

示例11: uptimeToString

import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
public static String uptimeToString(long uptime) {
    return DurationFormatUtils.formatDuration(uptime, "d 'Days' H 'Hours' m 'Minutes' s 'Seconds'\n");
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:4,代码来源:ServerUtil.java

示例12: ApplicationInformation

import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
ApplicationInformation(ApplicationReport appReport) {
  displayStringsMap = new EnumMap<>(Columns.class);
  appid = appReport.getApplicationId().toString();
  displayStringsMap.put(Columns.APPID, appid);
  user = appReport.getUser();
  displayStringsMap.put(Columns.USER, user);
  type = appReport.getApplicationType().toLowerCase();
  displayStringsMap.put(Columns.TYPE, type);
  state = appReport.getYarnApplicationState().toString().toLowerCase();
  name = appReport.getName();
  displayStringsMap.put(Columns.NAME, name);
  queue = appReport.getQueue();
  displayStringsMap.put(Columns.QUEUE, queue);
  priority = 0;
  usedContainers =
      appReport.getApplicationResourceUsageReport().getNumUsedContainers();
  displayStringsMap.put(Columns.CONT, String.valueOf(usedContainers));
  reservedContainers =
      appReport.getApplicationResourceUsageReport()
        .getNumReservedContainers();
  displayStringsMap.put(Columns.RCONT, String.valueOf(reservedContainers));
  usedVirtualCores =
      appReport.getApplicationResourceUsageReport().getUsedResources()
        .getVirtualCores();
  displayStringsMap.put(Columns.VCORES, String.valueOf(usedVirtualCores));
  usedMemory =
      appReport.getApplicationResourceUsageReport().getUsedResources()
        .getMemory() / 1024;
  displayStringsMap.put(Columns.MEM, String.valueOf(usedMemory) + "G");
  reservedVirtualCores =
      appReport.getApplicationResourceUsageReport().getReservedResources()
        .getVirtualCores();
  displayStringsMap.put(Columns.RVCORES,
      String.valueOf(reservedVirtualCores));
  reservedMemory =
      appReport.getApplicationResourceUsageReport().getReservedResources()
        .getMemory() / 1024;
  displayStringsMap.put(Columns.RMEM, String.valueOf(reservedMemory) + "G");
  attempts = appReport.getCurrentApplicationAttemptId().getAttemptId();
  nodes = 0;
  runningTime = Time.now() - appReport.getStartTime();
  time = DurationFormatUtils.formatDuration(runningTime, "dd:HH:mm");
  displayStringsMap.put(Columns.TIME, String.valueOf(time));
  progress = appReport.getProgress() * 100;
  displayStringsMap.put(Columns.PROGRESS, String.format("%.2f", progress));
  // store in GBSeconds
  memorySeconds =
      appReport.getApplicationResourceUsageReport().getMemorySeconds() / 1024;
  displayStringsMap.put(Columns.MEMSECS, String.valueOf(memorySeconds));
  vcoreSeconds =
      appReport.getApplicationResourceUsageReport().getVcoreSeconds();
  displayStringsMap.put(Columns.VCORESECS, String.valueOf(vcoreSeconds));
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:54,代码来源:TopCLI.java

示例13: convertTimeMs

import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
private String convertTimeMs(long timeMs) {
  if (timeMs < 1000) {
    return Long.toString(timeMs) + " msec";
  }
  return DurationFormatUtils.formatDuration(timeMs, "HH:mm:ss") + " HH:MM:SS";
}
 
开发者ID:linkedin,项目名称:dr-elephant,代码行数:7,代码来源:GenericSkewHeuristic.java

示例14: format

import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
private static String format(long miliseconds)
{
    return DurationFormatUtils.formatDuration(miliseconds, "mm:ss");
}
 
开发者ID:MrLittleKitty,项目名称:AnnihilationPro,代码行数:5,代码来源:AnnounceBar.java

示例15: getStringRepresentation

import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
@Override
public String getStringRepresentation() {
    return "Bericht älter als " + DurationFormatUtils.formatDuration(maxAge, "dd", false) + " Tag(e)";
}
 
开发者ID:Torridity,项目名称:dsworkbench,代码行数:5,代码来源:AgeFilter.java


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