Date type in CSV file

Hi,


I have 3/12/16 as a value in CSV file. It’s detected as date as expected and it’s considered to be 12 March 2016. I want it to be detected as 3 December 2016 instead. How to achieve this ?
Also 2-Jan-16 is detected as Date type but not 2-Jan.


Thanks in advance.

Hi,


Well, DateTime values are dependent upon your default locale set of your system/environment. You can specify some another region(locale) whose order is day/month/year, such as below code:
e.g
Sample code:

[Java]

TxtLoadOptions loadOptions = new TxtLoadOptions(LoadFormat.CSV);
loadOptions.setRegion(CountryCode.UNITED_KINGDOM);
Workbook workbook = new Workbook(strFilePath, loadOptions);


Hope, this helps a bit.

Thank you.

Thank you for the useful reply. But it will be better if I can set the date format for parsing such as m/d/y,d/m/y etc. Is it possible?

Hi,


I am afraid, by default, this might not be possible while loading/parsing the CSV file format directly and you got to set the relevant region (e.g which specifies in “dd/mm/yy” etc. for your needs) for your underlying DateTime values.

Thank you.

Hi,

Thanks for using Aspose.Cells.

For your requirement, you can implement your own parser to parse all data by property TxtLoadOptions.PreferredParsers.