java lib to handle csv date column

Handle csv column:especially date format

I have a task to handle the date between oracle and csv. So want to find out some lib to  parse some CSV I do not know.You can assign any delimiter.You can use opencsv or supercsv.But the most difficult point is that there is very hard to handle the date format.To read the opencsv api,I cannot find out any date handle process around that.But supercsv with a method like this,given as below:

http://supercsv.sourceforge.net/apidocs/index.html

public class FmtDate
extends CellProcessorAdaptor
implements DateCellProcessor
Converts a date into a formatted string using the SimpleDateFormat class. If you want to convert from a String to a Date, use the ParseDate processor.

Some example date formats you can use are:
"dd/MM/yyyy" (formats a date as "25/12/2011")
"dd-MMM-yy" (formats a date as "25-Dec-11")
"yyyy.MM.dd.HH.mm.ss" (formats a date as "2011.12.25.08.36.33"
"E, dd MMM yyyy HH:mm:ss Z" (formats a date as "Tue, 25 Dec 2011 08:36:33 -0500")

Since:
1.50
Author:
Dominique De Vito, James Bassett

You need to assign a format you can get first, sometime it just like simpledateformat,which is not what I want.

Last,I get the answer at stackoverflow.That is one man who with exprienced:

"i had to use a csv parser about 5 years ago. seems there are at least two csv standards:http://en.wikipedia.org/wiki/Comma-separated_values and what microsoft does in excel.

i found this libaray which eats both: http://ostermiller.org/utils/CSV.html, but afaik, it has no way of inferring what data type the columns were."

find this link:http://stackoverflow.com/questions/843997/csv-parsing-in-java-working-example

click into http://ostermiller.org/utils/DateTimeParse.html

That's very cool,

// No configuration needed, the following just work
Date d1 = new DateTimeParse().parse("January 1, 1805");
Date d2 = new DateTimeParse().parse("1805-03-24 11:21:33");
Date d3 = new DateTimeParse().parse("11:21 Jan 4th, 1805");
Date d4 = new DateTimeParse().parse("03-04-1805");
Issue done.
 
posted on 2013-02-05 16:29  jnuyao  阅读(325)  评论(0编辑  收藏  举报