I have written a generic CSV file reader that I'm trying to use to read some pre-generated CSV data files. These files contain price information and a timestamp in the following format
lTid,cDealable,NAME,TIMESTAMP,BID,ASK <--- The header
1705852073,D,EUR/USD,2011-10-02 17:00:16.123000000,1.334400,1.334600
In my code I have assumed prices are, as you would expect, numeric, text is a String and dates are Java Date (it's a little more complex but you get the idea). For dates the code allows you to pass a parsing template in. Up to now this has worked fine but I'm a little foxed as to what to do with these files (I have no control over the format and they are very large). As you will see the date has the form
2011-10-02 17:00:16.123000000
the six trailing zeros are always zero (i.e. the file time precision is down to milliseconds)
Ideally I would be able to use the pattern "yyyy-MM-dd HH:mm:ss.SSS
" but sadly the parsing logic in SimpleDateFormat interprets ".123000000
" as 123,000,000
milliseconds instead of 123ms.
Clearly if this were not a generic reader I could simply truncate the date string but I don't have that choice. Is there any way to get the parse statement to use the ms digits only and ignore the trailing zeros?