本文整理匯總了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());
}