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


Java NumberFormat.getPercentInstance方法代码示例

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


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

示例1: toString

import java.text.NumberFormat; //导入方法依赖的package包/类
@Override
public String toString()
{
    NumberFormat percentFormat = NumberFormat.getPercentInstance();
    percentFormat.setMinimumFractionDigits(2);
    StringBuilder sb = new StringBuilder();
    sb.append("UA: ");
    sb.append(percentFormat.format(getUA()));
    sb.append('\t');
    sb.append("LA: ");
    sb.append(percentFormat.format(getLA()));
    sb.append('\t');
    sb.append("DA: ");
    sb.append(percentFormat.format(getDA()));
    sb.append('\t');
    sb.append("sentences: ");
    sb.append(sentenceCount);
    sb.append('\t');
    sb.append("speed: ");
    sb.append(sentenceCount / (float)(System.currentTimeMillis() - start) * 1000);
    sb.append(" sent/s");
    return sb.toString();
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:24,代码来源:Evaluator.java

示例2: SPTBase

import java.text.NumberFormat; //导入方法依赖的package包/类
protected SPTBase(String phaseName, 
                  String[] bindingNames, 
                  String[] annotationTypes,
                  boolean debugMode,
                  boolean groupMatchingMode, 
                  MatchMode matchMode, 
                  Rule[] rules,
                  Predicate[][] predicatesByType) {
  percentFormat = NumberFormat.getPercentInstance();
  percentFormat.setMinimumFractionDigits(3);
  this.phaseName = phaseName;
  this.bindingNames = bindingNames;
  this.annotationTypes = annotationTypes;
  this.debugMode = debugMode;
  this.groupMatchingMode = groupMatchingMode;
  this.matchMode = matchMode;
  this.rules = rules;
  this.predicatesByType = predicatesByType;
}
 
开发者ID:victorward,项目名称:recruitervision,代码行数:20,代码来源:SPTBase.java

示例3: testEquals

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {
    StandardPieItemLabelGenerator g1 = new StandardPieItemLabelGenerator();
    StandardPieItemLabelGenerator g2 = new StandardPieItemLabelGenerator();
    assertTrue(g1.equals(g2));
    assertTrue(g2.equals(g1));
    
    g1 = new StandardPieItemLabelGenerator(
        "{0}", new DecimalFormat("#,##0.00"), NumberFormat.getPercentInstance()
    );
    assertFalse(g1.equals(g2));
    g2 = new StandardPieItemLabelGenerator(
        "{0}", new DecimalFormat("#,##0.00"), NumberFormat.getPercentInstance()
    );
    assertTrue(g1.equals(g2));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:StandardPieItemLabelGeneratorTests.java

示例4: percent2

import java.text.NumberFormat; //导入方法依赖的package包/类
public static String percent2(double p1, double p2)
{
	String str;
	double p3 = p1 / p2;
	NumberFormat nf = NumberFormat.getPercentInstance();
	nf.setMinimumFractionDigits(0);
	str = nf.format(p3);
	return str;
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:10,代码来源:TDevice.java

示例5: percent2

import java.text.NumberFormat; //导入方法依赖的package包/类
public static String percent2(double p1, double p2) {
    String str;
    double p3 = p1 / p2;
    NumberFormat nf = NumberFormat.getPercentInstance();
    nf.setMinimumFractionDigits(0);
    str = nf.format(p3);
    return str;
}
 
开发者ID:FallenCrood,项目名称:Review-,代码行数:9,代码来源:TDevice.java

示例6: onActivityCreate

import java.text.NumberFormat; //导入方法依赖的package包/类
@Override
protected void onActivityCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_rx_file_download);
    ButterKnife.bind(this);
    setTitle("文件下载");

    numberFormat = NumberFormat.getPercentInstance();
    numberFormat.setMinimumFractionDigits(2);

    checkSDCardPermission();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:RxFileDownloadActivity.java

示例7: onActivityCreate

import java.text.NumberFormat; //导入方法依赖的package包/类
@Override
protected void onActivityCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_form_upload);
    ButterKnife.bind(this);
    setTitle("文件上传");

    numberFormat = NumberFormat.getPercentInstance();
    numberFormat.setMinimumFractionDigits(2);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:FormUploadActivity.java

示例8: onActivityCreate

import java.text.NumberFormat; //导入方法依赖的package包/类
@Override
protected void onActivityCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_file_download);
    ButterKnife.bind(this);
    setTitle("简单文件下载");

    numberFormat = NumberFormat.getPercentInstance();
    numberFormat.setMinimumFractionDigits(2);

    checkSDCardPermission();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:SimpleDownloadActivity.java

示例9: getString

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Returns a {@code String} representation of the current progress.
 * By default, this returns a simple percentage {@code String} based on
 * the value returned from {@code getPercentComplete}.  An example
 * would be the "42%".  You can change this by calling {@code setString}.
 *
 * @return the value of the progress string, or a simple percentage string
 *         if the progress string is {@code null}
 * @see    #setString
 */
public String getString(){
    if (progressString != null) {
        return progressString;
    } else {
        if (format == null) {
            format = NumberFormat.getPercentInstance();
        }
        return format.format(new Double(getPercentComplete()));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:JProgressBar.java

示例10: CPUTestCase

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Creates a new instance of CPUTestCase
 */
public CPUTestCase(String name) {
    super(name);
    percentFormat = NumberFormat.getPercentInstance();
    percentFormat.setMaximumFractionDigits(1);
    percentFormat.setMinimumFractionDigits(0);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:CPUTestCase.java

示例11: percent

import java.text.NumberFormat; //导入方法依赖的package包/类
public static String percent(double p1, double p2) {
    String str;
    double p3 = p1 / p2;
    NumberFormat nf = NumberFormat.getPercentInstance();
    nf.setMinimumFractionDigits(2);
    str = nf.format(p3);
    return str;
}
 
开发者ID:yangxp108,项目名称:MVPArms_Fragment-fragment,代码行数:9,代码来源:DeviceUtils.java

示例12: StandardPieItemLabelGenerator

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Creates an item label generator using default number formatters.
 */
public StandardPieItemLabelGenerator() {
    this(
        DEFAULT_SECTION_LABEL_FORMAT, 
        NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance()
    );
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:10,代码来源:StandardPieItemLabelGenerator.java

示例13: testPercentFormat

import java.text.NumberFormat; //导入方法依赖的package包/类
void testPercentFormat() {
    NumberFormat format = NumberFormat.getPercentInstance(Locale.US);
    TestFormattedTextField ftf = create(format);
    ftf.setValue(.34);

    System.err.println("Testing NumberFormat.getPercentInstance(Locale.US)");

    // test inserting individual characters
    ftf.test(0, 0, "1", .14);
    ftf.test(2, 0, "2", 1.42);
    ftf.test(1, 0, "0", 1.02);

    // test inserting several characters at once - e.g. from clipboard
    ftf.test(0, 0, "1024", 10.24);
    ftf.test(3, 0, "333", 103.33);
    ftf.test(6, 0, "77", 10333.77);
    ftf.test(4, 0, "99", 10399.77);
    ftf.test(6, 0, "00", 10390.07);

    // test inserting strings that contain some formatting
    ftf.test(0, 0, "2,2", 2290.07);
    ftf.test(2, 0, "2,2", 222.27);
    ftf.test(4, 0, "2,2", 222.22);
    ftf.test(6, 0, "33,33", 2222233.33);

    // test delete
    ftf.test(0, 0, DELETE, 222233.33);
    ftf.test(10, 0, DELETE, 222233.33);
    ftf.test(5, 0, DELETE, 22223.33);
    ftf.test(6, 0, DELETE, 2222.33);

    // test backspace
    ftf.test(0, 0, BACKSPACE, 2222.33);
    ftf.test(7, 0, BACKSPACE, 222.23);
    ftf.test(4, 0, BACKSPACE, 22.23);
    ftf.test(2, 0, BACKSPACE, 2.23);

    // test replacing selection
    ftf.test(0, 1, "555", 555.23);
    ftf.test(4, 2, "555", 5555.55);
    ftf.test(2, 3, "1", 551.55);
    ftf.test(3, 2, "6", 55.65);
    ftf.test(4, 2, "12", 556.12);
    ftf.test(3, 4, "0", 5.5);
    ftf.test(0, 3, "111222333444555", 1112223334445.55);

    // test deleting selection
    ftf.test(0, 2, DELETE, 12223334445.55);
    ftf.test(0, 3, BACKSPACE, 223334445.55);
    ftf.test(12, 2, DELETE, 2233344.45);
    ftf.test(9, 2, BACKSPACE, 22333.44);
    ftf.test(4, 3, DELETE, 223.44);
    ftf.test(1, 2, BACKSPACE, 23.44);
    ftf.test(3, 3, DELETE, .23);
    ftf.test(1, 2, BACKSPACE, .02);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:57,代码来源:Test6462562.java

示例14: onBindViewHolder

import java.text.NumberFormat; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (position == 0) {
        HeaderHolder headerHolder = (HeaderHolder) holder;
        //专辑详情
        Glide.with(mContext).load(mAlbum.getCoverUrlMiddle()).into(headerHolder.mIvAlbum);
        headerHolder.mTvAlbumTitle.setText(mAlbum.getAlbumTitle());
        LastUpTrack lastUptrack = mAlbum.getLastUptrack();
        StringBuilder sb = new StringBuilder();
        headerHolder.mTvLastTrack.setText(sb.append("更新至").append(TimeUtils.formatDate(new Date(lastUptrack.getCreatedAt()))).append("  ").append(lastUptrack.getTrackTitle()).toString());
        sb.setLength(0);
        headerHolder.mTvPlayCount.setText(sb.append(StringUtils.formPlayCount(mAlbum.getPlayCount())).append("次播放").toString());
        sb.setLength(0);
        headerHolder.mTvTrackCount.setText(sb.append(mAlbum.getIncludeTrackCount()).append("集").toString());
        //订阅状态
        boolean isSubscribe = mAlbumDao.isSubscribe(mAlbumId);
        headerHolder.mTvSubscribe.setText(isSubscribe ? "已订阅" : "订阅");
        LevelListDrawable ld = (LevelListDrawable) headerHolder.mTvSubscribe.getBackground();
        ld.setLevel(isSubscribe ? 1 : 0);

        if (mHistory != null) {
            headerHolder.mRlHistoryBox.setVisibility(View.VISIBLE);
            sb.setLength(0);
            headerHolder.mTvHistoryTitle.setText(sb.append("继续播放:").append(mHistory.getTrackTitle()).toString());
            sb.setLength(0);
            NumberFormat nf = NumberFormat.getPercentInstance();
            //返回数的整数部分所允许的最大位数
            nf.setMaximumIntegerDigits(3);
            //返回数的小数部分所允许的最大位数
            nf.setMaximumFractionDigits(0);
            headerHolder.mTvProgress.setText(sb.append("已播  ").append(nf.format(mHistory.getBreakPos() / (double) mHistory.getDuration())).toString());
            headerHolder.mIvTingSwitch.setImageLevel((XmlyManager.get().isPlaying() && playTrackId == mHistory.getTrackId()) ? 1 : 0);
        } else {
            headerHolder.mRlHistoryBox.setVisibility(View.GONE);
        }

    } else {
        Track track = mTracks.get(position);
        TrackDetailHolder detailHolder = (TrackDetailHolder) holder;
        detailHolder.mTvTrackTitle.setText(track.getTrackTitle());
        detailHolder.mTvTrackTitle.setTextColor(track.getDataId() == playTrackId
                ? mContext.getResources().getColor(R.color.second_base_color)
                : mContext.getResources().getColor(R.color.new_text_color_first));
        detailHolder.mIvTingSwitch.setImageLevel(0);
        if (track.getDataId() == playTrackId)
            detailHolder.mIvTingSwitch.setImageLevel(XmlyManager.get().isPlaying() ? 1 : 0);
        detailHolder.mTvCreated.setText(TimeUtils.getInstance().getDateString(new Date(track.getCreatedAt())));
        detailHolder.mTvDuration.setText(new SimpleDate().formDuration(track.getDuration()));
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:51,代码来源:TingAlbumDetailAdapter.java

示例15: StandardPieSectionLabelGenerator

import java.text.NumberFormat; //导入方法依赖的package包/类
/**
 * Creates a new section label generator using 
 * {@link #DEFAULT_SECTION_LABEL_FORMAT} as the label format string, and 
 * platform default number and percentage formatters.
 */
public StandardPieSectionLabelGenerator() {
    this(DEFAULT_SECTION_LABEL_FORMAT, NumberFormat.getNumberInstance(), 
            NumberFormat.getPercentInstance());
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:10,代码来源:StandardPieSectionLabelGenerator.java


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