use of java.text.NumberFormat in project translationstudio8 by heartsome.
the class TransProgressFAResult method getNotTransParasRatio.
/**
* 获取未翻译文本段的比例
* @return 如25.00%
*/
public String getNotTransParasRatio() {
float ratio = (float) notTransPara / (notTransPara + translatedPara);
NumberFormat format = NumberFormat.getNumberInstance();
format.setMaximumFractionDigits(2);
return format.format(ratio * 100) + "%";
}
use of java.text.NumberFormat in project translationstudio8 by heartsome.
the class TransProgressFAResult method getTransParasRatio.
/**
* 获取已翻译文本段的比例
* @return 如25.00%
*/
public String getTransParasRatio() {
float ratio = (float) translatedPara / (notTransPara + translatedPara);
NumberFormat format = NumberFormat.getNumberInstance();
format.setMaximumFractionDigits(2);
return format.format(ratio * 100) + "%";
}
use of java.text.NumberFormat in project translationstudio8 by heartsome.
the class EditProgressFAResult method getApprovedWordsRatio.
/**
* 获取已批准字数的比例
* @return 如25.00%
*/
public String getApprovedWordsRatio() {
float ratio = (float) approvedWords / (notApprovedWords + approvedWords);
NumberFormat format = NumberFormat.getNumberInstance();
format.setMaximumFractionDigits(2);
return format.format(ratio * 100) + "%";
}
use of java.text.NumberFormat in project spring-framework by spring-projects.
the class DefaultListableBeanFactoryTests method testCustomEditor.
@Test
public void testCustomEditor() {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
@Override
public void registerCustomEditors(PropertyEditorRegistry registry) {
NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
}
});
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("myFloat", "1,1");
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
bd.setPropertyValues(pvs);
lbf.registerBeanDefinition("testBean", bd);
TestBean testBean = (TestBean) lbf.getBean("testBean");
assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}
use of java.text.NumberFormat in project spring-framework by spring-projects.
the class DefaultListableBeanFactoryTests method testCustomTypeConverter.
@Test
public void testCustomTypeConverter() {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
lbf.setTypeConverter(new CustomTypeConverter(nf));
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("myFloat", "1,1");
ConstructorArgumentValues cav = new ConstructorArgumentValues();
cav.addIndexedArgumentValue(0, "myName");
cav.addIndexedArgumentValue(1, "myAge");
lbf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class, cav, pvs));
TestBean testBean = (TestBean) lbf.getBean("testBean");
assertEquals("myName", testBean.getName());
assertEquals(5, testBean.getAge());
assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}
Aggregations