Date representation in csv file is to be changed

When i convert xls/xlsx to csv than in that csv file date is coming as Fri Nov 11 00:00:00 IST 1988. But i need yyyy-mm-dd format. What can i do in the following code: [code]

            row = (HSSFRow) rowIterator.next();

            // For each row, iterate through each columns
            Iterator<Cell> cellIterator = row.cellIterator();
            while (cellIterator.hasNext()) {

                cell = (HSSFCell) cellIterator.next();
                    if(cell.getCellType() == Cell.CELL_TYPE_NUMERIC)
                    {
                        if(HSSFDateUtil.isCellDateFormatted(cell))
                        {

                            data.append(cell.getDateCellValue() + "|");

                        }else
                            data.append(cell.getNumericCellValue() + "|");
                    }else if(cell.getCellType() == Cell.CELL_TYPE_BOOLEAN)
                    {
                        data.append(cell.getBooleanCellValue() + "|");
                    } else if(cell.getCellType() == Cell.CELL_TYPE_STRING)
                    {
                        data.append(cell.getStringCellValue() + "|");
                    }  
                    else if(cell.getCellType() == Cell.CELL_TYPE_BLANK)
                    {
                        data.append("" + "|");
                    }
                    else
                    {
                        data.append(cell + ",");

                    }
            }data.append("\r\n");

Answers


For date format try this if condition on your date formatted cell.

if(HSSFDateUtil.isCellDateFormatted(cell))
      {
     // data.append(cell.getDateCellValue() + "|");
      SimpleDateFormat DtFormat = new SimpleDateFormat("yyyy-mm-dd");
      Date date=Test.getRow(RowNum).getCell(CellNum).getDateCellValue();
      data.append(date);
      }

Need Your Help

How to let Qt Tree model work with QSet?

c++ qt vector set treemodel

I want to build a tree with items which are always automatically sorted under a tree node when adding, renaming, and doing other operation. std::set seems a good candidates for my data container.

GitHub API issue - listing starred repos

json api curl github repository

I'm trying to list all of the repos that I'm currently starring, and I do:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.