Hello,
i have excel file and i want to read some column and insert it in DB, any way i want to read Column with Date
PHP Code:
The column in the Excel file, which i want to be read
Date
========
14.12.2010
15.12.2010
16.12.2010
17.12.2010
18.12.2010
19.12.2010
20.12.2010
21.12.2010
22.12.2010
public class Date_DB {
private String name;
private Date dateOfCommission;
//Setters und Getters
}
Calss To read from Excel
Date_DB pp = new Date_DB();
pp.setDateOfCommission(row.getCell(12).getDateCellValue()); ///date
set.add(pp);
But it reads the Date as the flowing:
HTML Code:
Tue Dec 14 00:00:00 CET 2010
Wed Dec 15 00:00:00 CET 2010
Thu Dec 16 00:00:00 CET 2010
Fri Dec 17 00:00:00 CET 2010
Sat Dec 18 00:00:00 CET 2010
Sun Dec 19 00:00:00 CET 2010
Mon Dec 20 00:00:00 CET 2010
Tue Dec 21 00:00:00 CET 2010
Wed Dec 22 00:00:00 CET 2010
Now what i wish is to reformat this Date to be exactly like in the Excel file (have Format ""dd.MM.yyyy" ) and store them ad a Date in the Set
I read a lot about Calender Format, but i didn't find any thing really helpful, i know that, but now i need really to change its format to something like "dd.MM.yyyy", and i know that i should use SimpleDateFormat, but some how i don'nt know how to use it right during reding the Date cells from the excel file
The Problem that SimpleDateFormat return Type String and i need just to deal with Date
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
pp.setDateOfCommission(sdf.format(row.getCell(12).getDateCellValue())); // error: The method setDateOfCommission(Date) in the type Date_DB is not applicable for the arguments (String)
or something like that
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
Date date = sdf.parse(pp.setDateOfCommission(row.getCell(12).getDateCellValue())); //error: The method parse(String) in the type DateFormat is not applicable for the arguments (void)
so how to deal with it?
Any Help?