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


Java Strings.format1Decimals方法代码示例

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


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

示例1: toString

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
@Override
public String toString() {
    long bytes = getBytes();
    double value = bytes;
    String suffix = "b";
    if (bytes >= ByteSizeUnit.C5) {
        value = getPbFrac();
        suffix = "pb";
    } else if (bytes >= ByteSizeUnit.C4) {
        value = getTbFrac();
        suffix = "tb";
    } else if (bytes >= ByteSizeUnit.C3) {
        value = getGbFrac();
        suffix = "gb";
    } else if (bytes >= ByteSizeUnit.C2) {
        value = getMbFrac();
        suffix = "mb";
    } else if (bytes >= ByteSizeUnit.C1) {
        value = getKbFrac();
        suffix = "kb";
    }
    return Strings.format1Decimals(value, suffix);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:ByteSizeValue.java

示例2: toString

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
@Override
public String toString() {
    long singles = singles();
    double value = singles;
    String suffix = "";
    if (singles >= SizeUnit.C5) {
        value = petaFrac();
        suffix = "p";
    } else if (singles >= SizeUnit.C4) {
        value = teraFrac();
        suffix = "t";
    } else if (singles >= SizeUnit.C3) {
        value = gigaFrac();
        suffix = "g";
    } else if (singles >= SizeUnit.C2) {
        value = megaFrac();
        suffix = "m";
    } else if (singles >= SizeUnit.C1) {
        value = kiloFrac();
        suffix = "k";
    }

    return Strings.format1Decimals(value, suffix);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:SizeValue.java

示例3: toString

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
@Override
public String toString() {
    long bytes = bytes();
    double value = bytes;
    String suffix = "b";
    if (bytes >= ByteSizeUnit.C5) {
        value = pbFrac();
        suffix = "pb";
    } else if (bytes >= ByteSizeUnit.C4) {
        value = tbFrac();
        suffix = "tb";
    } else if (bytes >= ByteSizeUnit.C3) {
        value = gbFrac();
        suffix = "gb";
    } else if (bytes >= ByteSizeUnit.C2) {
        value = mbFrac();
        suffix = "mb";
    } else if (bytes >= ByteSizeUnit.C1) {
        value = kbFrac();
        suffix = "kb";
    }
    return Strings.format1Decimals(value, suffix);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:ByteSizeValue.java

示例4: toString

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
/**
 * Returns a {@link String} representation of the current {@link TimeValue}.
 *
 * Note that this method might produce fractional time values (ex 1.6m) which cannot be
 * parsed by method like {@link TimeValue#parse(String, String, int)}.
 */
@Override
public String toString() {
    if (duration < 0) {
        return Long.toString(duration);
    }
    long nanos = nanos();
    if (nanos == 0) {
        return "0s";
    }
    double value = nanos;
    String suffix = "nanos";
    if (nanos >= C6) {
        value = daysFrac();
        suffix = "d";
    } else if (nanos >= C5) {
        value = hoursFrac();
        suffix = "h";
    } else if (nanos >= C4) {
        value = minutesFrac();
        suffix = "m";
    } else if (nanos >= C3) {
        value = secondsFrac();
        suffix = "s";
    } else if (nanos >= C2) {
        value = millisFrac();
        suffix = "ms";
    } else if (nanos >= C1) {
        value = microsFrac();
        suffix = "micros";
    }
    return Strings.format1Decimals(value, suffix);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:39,代码来源:TimeValue.java

示例5: toString

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
@Override
public String toString() {
    if (duration < 0) {
        return Long.toString(duration);
    }
    long nanos = nanos();
    if (nanos == 0) {
        return "0s";
    }
    double value = nanos;
    String suffix = "nanos";
    if (nanos >= C6) {
        value = daysFrac();
        suffix = "d";
    } else if (nanos >= C5) {
        value = hoursFrac();
        suffix = "h";
    } else if (nanos >= C4) {
        value = minutesFrac();
        suffix = "m";
    } else if (nanos >= C3) {
        value = secondsFrac();
        suffix = "s";
    } else if (nanos >= C2) {
        value = millisFrac();
        suffix = "ms";
    } else if (nanos >= C1) {
        value = microsFrac();
        suffix = "micros";
    }
    return Strings.format1Decimals(value, suffix);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:33,代码来源:TimeValue.java

示例6: toString

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
@Override
public String toString() {
    return "[" + nodeId + "][" + nodeName + "][" + path + "] free: " + new ByteSizeValue(getFreeBytes()) +
            "[" + Strings.format1Decimals(getFreeDiskAsPercentage(), "%") + "]";
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:6,代码来源:DiskUsage.java


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