本文整理汇总了Java中org.apache.commons.lang.time.DurationFormatUtils.formatDurationWords方法的典型用法代码示例。如果您正苦于以下问题:Java DurationFormatUtils.formatDurationWords方法的具体用法?Java DurationFormatUtils.formatDurationWords怎么用?Java DurationFormatUtils.formatDurationWords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang.time.DurationFormatUtils
的用法示例。
在下文中一共展示了DurationFormatUtils.formatDurationWords方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: displayStats
import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
private void displayStats(long insertedCnt) {
float percentComplete = (float) insertedCnt / (float) rowCnt;
long now = System.currentTimeMillis();
long elapsedTime = now - startTime;
long timeRemaining = ((long) (((float) (now - startTime)) / percentComplete)) - elapsedTime;
String elapsedTimeStr = DurationFormatUtils.formatDurationWords(elapsedTime, true, true);
String timeRemainingStr = DurationFormatUtils.formatDurationWords(timeRemaining, true,
true);
System.out.println("Inserted " + insertedCnt + " rows (" + readyToFindCnt + " readyToFind, "
+ readyToProcessCnt + " readyToProcess, " + readyToPostProcessCnt
+ " readyToPostProcess) in " + elapsedTimeStr + ". "
+ ((int) (percentComplete * 100)) + " % complete, " + timeRemainingStr
+ " remaining.");
}
示例2: createLastCheckInTime
import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
private String createLastCheckInTime(IModel<NodeDto> nodeModel) {
NodeDto node = nodeModel.getObject();
Long time = node.getLastCheckInTime();
if (time == null || time == 0) {
return "";
}
//todo i18n
return DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - time, true, true)
+ " ago";
}
示例3: mergeCurrentEvent
import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
private SecqMeEventVO mergeCurrentEvent(SecqMeEventVO userLatestEvent,
SecqMeEventVO currentEmergencyEvent,
String currentEmergencyAudioStream,
String base64VideoString,
InputStream videoInputStream,
Boolean triggerNotification)
throws CoreException {
myLog.debug("Merging user : " + currentEmergencyEvent.getUserVO().getUserid()
+ " current emergency Event with user latest running Event..");
// Forming the event Message
long durationFromLastEvent = userLatestEvent.getStartTime().getTime()
- currentEmergencyEvent.getStartTime().getTime();
String durationStr = DurationFormatUtils.formatDurationWords(durationFromLastEvent, true, true);
EventStatusType eventStatusType = EventStatusType.EMERGENCY;
String mediaFilePath = null;
// Remove all the '-' characters
durationStr = durationStr.replaceAll("-", "");
// StringBuffer buf = new StringBuffer();
//// buf.append(userLatestEvent.getMessage());
//// buf.append("\n\n");
String emergencyMsg = "Received emergency request from user, ";
if (currentEmergencyAudioStream != null) {
emergencyMsg = "Received emergency voice message from user, ";
eventStatusType = EventStatusType.EMERGENCY_AUDIO;
} else if (base64VideoString != null) {
emergencyMsg = "Received emergency video from user, ";
eventStatusType = EventStatusType.EMERGENCY_VIDEO;
}
// emergencyMsg = emergencyMsg + durationStr + " after WatchOverMe request submitted";
// buf.append(emergencyMsg);
// buf.append(durationStr);
// buf.append(" after Watch Over Me request submitted.");
// userLatestEvent.setMessage(buf.toString());
userLatestEvent.setEventType(currentEmergencyEvent.getEventType());
userLatestEvent.setEmergencyTriggerAt(new Date());
//process to notify to user's contact
if (triggerNotification == null || triggerNotification) {
processEmergencyEvent(userLatestEvent);
}
MediaFileType mediaFileType = null;
String encodedMediaFile = null;
if (base64VideoString != null) {
mediaFileType = MediaFileType.VIDEO;
encodedMediaFile = base64VideoString;
userLatestEvent.setEnableVideo(true);
} else if (currentEmergencyAudioStream != null) {
mediaFileType = MediaFileType.AUDIO;
encodedMediaFile = currentEmergencyAudioStream;
userLatestEvent.setEnableAudio(true);
}
if (videoInputStream != null) {
userLatestEvent.setEnableVideo(true);
insertEventLogRecord(userLatestEvent, eventStatusType, emergencyMsg, null, null, null, MediaFileType.VIDEO, videoInputStream);
} else if (encodedMediaFile != null) {
insertEventLogRecord(userLatestEvent, eventStatusType, emergencyMsg, null, null, null, mediaFileType, encodedMediaFile);
} else {
insertEventLogRecord(userLatestEvent, eventStatusType, emergencyMsg, null, null, null);
}
getSecqMeEventDAO().update(userLatestEvent);
return userLatestEvent;
}
示例4: getDuration
import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
private String getDuration(long milliseconds) {
return DurationFormatUtils.formatDurationWords(milliseconds, true, true);
}
示例5: format
import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
public static String format(long time) {
// Round up to the nearest second.
time += 20 - (time % 20);
return DurationFormatUtils.formatDurationWords(time * 50, true, true);
}
示例6: formatDuration
import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
/**
* Pretty formating of a duration in milliseconds.
* <p/>
* @param ms Milliseconds
* @return Pretty format of the duration
*/
public static String formatDuration(Long ms) {
return DurationFormatUtils.formatDurationWords(ms, true, true);
}