本文整理汇总了Java中org.apache.commons.lang.time.DurationFormatUtils.formatDurationHMS方法的典型用法代码示例。如果您正苦于以下问题:Java DurationFormatUtils.formatDurationHMS方法的具体用法?Java DurationFormatUtils.formatDurationHMS怎么用?Java DurationFormatUtils.formatDurationHMS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang.time.DurationFormatUtils
的用法示例。
在下文中一共展示了DurationFormatUtils.formatDurationHMS方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
/**
* output as:
* 551 150 1000 0:00:01.701
* step1(ms) step2(ms) step3(ms) total duration
*/
@Override
public String toString() {
long currentTimeMillis = System.currentTimeMillis();
if(stops!=null && stops.size()>0){
List<Long> durationList = new ArrayList<Long>();
long last = this.startTime;
for(int i=0;i<stops.size();i++){
long cur = stops.get(i);
durationList.add(cur - last);
last = cur;
}
if (this.running) {
durationList.add(currentTimeMillis - last);
} else {
durationList.add(this.stopTime - last);
}
return StringUtils.join(durationList, "\t")+"\t"+DurationFormatUtils.formatDurationHMS(getTime(currentTimeMillis));
}else{
return DurationFormatUtils.formatDurationHMS(getTime(currentTimeMillis));
}
}
示例2: formatDuration
import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
String formatDuration() {
return DurationFormatUtils.formatDurationHMS((long) (1000 * Double
.valueOf(duration).doubleValue()));
}
示例3: toString
import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
public String toString() {
return DurationFormatUtils.formatDurationHMS(getTime());
}
示例4: toSplitString
import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
public String toSplitString() {
return DurationFormatUtils.formatDurationHMS(getSplitTime());
}
示例5: toLapString
import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
public String toLapString() {
return DurationFormatUtils.formatDurationHMS(getLapTime());
}
示例6: index
import org.apache.commons.lang.time.DurationFormatUtils; //导入方法依赖的package包/类
public static void index(Indexer indexer, String file) {
UriEncodingHandlingSameAsRetriever retriever = new UriEncodingHandlingSameAsRetriever();
LineIterator iterator = null;
long size = 0, rounds = 0;
try {
iterator = FileUtils.lineIterator(new File(file), "UTF-8");
String uri = null;
Set<String> uris;
String old = null;
Date start = Calendar.getInstance().getTime();
// iterate over the lines
while (iterator.hasNext()) {
String[] split = iterator.next().split("\\s+");
if (split.length > 2) {
// get the subject of the triple
uri = split[0];
if (uri.startsWith("<")) {
uri = uri.substring(1);
}
if (uri.endsWith(">")) {
uri = uri.substring(0, uri.length() - 1);
}
// if this subject is new
if (!uri.equals(old)) {
// retrieve other writings of this URI
uris = retriever.retrieveSameURIs(uri);
if (uris != null) {
for (String u : uris) {
indexer.index(u);
}
} else {
indexer.index(uri);
}
}
size++;
if (size % 100000 == 0) {
Date end = Calendar.getInstance().getTime();
rounds++;
String avgTime = DurationFormatUtils
.formatDurationHMS((end.getTime() - start.getTime()) / rounds);
LOGGER.info("Got 100000 entities...(Sum: {}, AvgTime: {})", size, avgTime);
}
}
}
} catch (IOException e) {
LOGGER.error("Exception while reading file. It will be ignored.", e);
} finally {
LineIterator.closeQuietly(iterator);
}
LOGGER.info("Successfully indexed {} triples", size);
}