本文整理汇总了Java中org.supercsv.cellprocessor.ParseBigDecimal类的典型用法代码示例。如果您正苦于以下问题:Java ParseBigDecimal类的具体用法?Java ParseBigDecimal怎么用?Java ParseBigDecimal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParseBigDecimal类属于org.supercsv.cellprocessor包,在下文中一共展示了ParseBigDecimal类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testConvertsToBasicObjects
import org.supercsv.cellprocessor.ParseBigDecimal; //导入依赖的package包/类
@Test
public void testConvertsToBasicObjects() throws Exception {
String csv = "Connor|John|16|1999-07-12|6" + decimalFormatSymbols.getDecimalSeparator() + "65\r\n";
String[] mapping = { "lastName", "firstName", "age", "birthDate", "savings" };
CellProcessor[] processors = { new NotNull(), new NotNull(), new ParseInt(), new ParseDate("yyyy-MM-dd"),
new ParseBigDecimal(decimalFormatSymbols) };
CsvPreference customPreference = new Builder('"', '|', "\r\n").build();
CsvBeanReader beanReader = new CsvBeanReader(new StringReader(csv), customPreference);
FeatureBean character = beanReader.read(FeatureBean.class, mapping, processors);
Assert.assertNotNull(character);
Assert.assertEquals("John", character.getFirstName());
Assert.assertEquals("Connor", character.getLastName());
Assert.assertEquals(16, character.getAge());
Assert.assertEquals(new SimpleDateFormat("yyyy-MM-dd").parse("1999-07-12"), character.getBirthDate());
Assert.assertEquals(new BigDecimal(6.65, new MathContext(3)), character.getSavings());
}
示例2: testConverterSupport
import org.supercsv.cellprocessor.ParseBigDecimal; //导入依赖的package包/类
@Test
public void testConverterSupport() throws Exception {
String csv = "Connor|John|16|1999-07-12|6" + decimalFormatSymbols.getDecimalSeparator() + "65\r\n";
String[] mapping = { "lastName", "firstName", "age", "birthDate", "savings" };
CellProcessor[] processors = { new NotNull(), new NotNull(), new ParseInt(), new ParseDate("yyyy-MM-dd"),
new ParseBigDecimal(decimalFormatSymbols) };
CsvPreference customPreference = new Builder('"', '|', "\r\n").build();
CsvBeanReader beanReader = new CsvBeanReader(new StringReader(csv), customPreference);
FeatureBean character = beanReader.read(FeatureBean.class, mapping, processors);
Assert.assertNotNull(character);
Assert.assertEquals("John", character.getFirstName());
Assert.assertEquals("Connor", character.getLastName());
Assert.assertEquals(16, character.getAge());
Assert.assertEquals(new SimpleDateFormat("yyyy-MM-dd").parse("1999-07-12"), character.getBirthDate());
Assert.assertEquals(new BigDecimal(6.65, new MathContext(3)), character.getSavings());
}