I have written following code:
CSVFormat csvFileFormat = CSVFormat.DEFAULT.withRecordSeparator("\n").withEscape('\\');
FileWriter fileWriter = new FileWriter(csvFile);
CSVPrinter csvFilePrinter = new CSVPrinter(fileWriter,csvFileFormat);
function printCSV(String fieldValue,String dataType,CSVPrinter csvFilePrinter){
if(dataType!=null && "date".equals(dataType)){
fieldValue = this.dateFormatter.format(new SimpleDateFormat("yyyy-MM-dd").parse(fieldValue));
}
csvFilePrinter.printRecord(fieldValue);
}
When the csv file is opened in excel sheet, only few cells are date formatted. I do not want date formatted and want to treat all cells as String. How can I do this?