1 package net.sf.pzfilereader.examples.numericsanddates;
2
3
4
5
6
7
8 import java.io.File;
9 import java.text.SimpleDateFormat;
10
11 import net.sf.pzfilereader.DataSet;
12 import net.sf.pzfilereader.DefaultPZParserFactory;
13 import net.sf.pzfilereader.DataSet;
14 import net.sf.pzfilereader.PZParser;
15
16 /**
17 * @author zepernick
18 *
19 * TODO To change the template for this generated type comment go to Window -
20 * Preferences - Java - Code Style - Code Templates
21 */
22 public class NumericsAndDates {
23 public static void main(final String[] args) throws Exception {
24 String mapping = getDefaultMapping();
25 String data = getDefaultDataFile();
26 call(mapping, data);
27 }
28
29 public static String getDefaultDataFile() {
30 return "INVENTORY-CommaDelimitedWithQualifier.txt";
31 }
32
33 public static String getDefaultMapping() {
34 return "INVENTORY-Delimited.pzmap.xml";
35 }
36
37 public static void call(String mapping, String data) throws Exception {
38
39 final SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
40
41
42
43
44 final PZParser pzparser = DefaultPZParserFactory.getInstance().newDelimitedParser(new File(mapping),
45 new File(data), ',', '\"', true);
46 final DataSet ds = pzparser.parse();
47
48 while (ds.next()) {
49 System.out.println("Item Desc: " + ds.getString("ITEM_DESC") + " (String)");
50 System.out.println("In Stock: " + ds.getInt("IN_STOCK") + " (int)");
51 System.out.println("Price: " + ds.getDouble("PRICE") + " (double)");
52 System.out.println("Received Dt: " + sdf.format(ds.getDate("LAST_RECV_DT")) + " (Date)");
53 System.out.println("===========================================================================");
54 }
55 }
56 }