Search in sources :

Example 1 with CsvWriter

use of org.simpleflatmapper.csv.CsvWriter in project SimpleFlatMapper by arnaudroger.

the class CsvWriterTest method testWriterWithOneManualColumnWithFormat.

@Test
public void testWriterWithOneManualColumnWithFormat() throws Exception {
    StringWriter sw = new StringWriter();
    final CsvWriter.CsvWriterDSL<DbObject> dbObjectCsvWriterDSL = CsvWriter.from(DbObject.class).skipHeaders();
    final CsvWriter<DbObject> to = dbObjectCsvWriterDSL.column("creation_time", new SimpleDateFormat("yyyyMMdd")).to(sw);
    to.append(newDbObject());
    assertEquals("20150606\r\n", sw.toString());
}
Also used : StringWriter(java.io.StringWriter) CsvWriter(org.simpleflatmapper.csv.CsvWriter) DbObject(org.simpleflatmapper.test.beans.DbObject) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Aggregations

StringWriter (java.io.StringWriter)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Test (org.junit.Test)1 CsvWriter (org.simpleflatmapper.csv.CsvWriter)1 DbObject (org.simpleflatmapper.test.beans.DbObject)1