sniger
asked on
apache poi date format - xssf
I set up a format for my cel:
before that I retrieve date from the database in the format cyymmdd, format it:
but the date is comletely out of whack in my excel spreadhseet
DataFormat df = wb.createDataFormat();
style = createBorderedStyle(wb);
style.setAlignment(CellStyle.ALIGN_RIGHT);
style.setFont(font1);
style.setDataFormat(df.getFormat("dd.MM.yyyy"));
styles.put("cell_pub_date", style);
before that I retrieve date from the database in the format cyymmdd, format it:
String year = "20" + field.substring(1,3);
String month = field.substring(3,5);
String day = field.substring(5,7);
SimpleDateFormat sf = new SimpleDateFormat("dd.MM.yyyy");
String date_s = day + "." + month + "." + year;
System.out.println(date_s);
try {
java.util.Date date = sf.parse(date_s);
System.out.println(date.toString());
c.setCellValue(date);
c.setCellStyle(styles.get("cell_pub_date"));
}
catch (Exception e) {
System.out.println( );
}
but the date is comletely out of whack in my excel spreadhseet
What do you mean "out of whack"? What does it look like after it ends up in Excel?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
krakatoa,
I changed the format to m/d/yy in my po style
In java se I assume it is SimpleDateFormat sf = new SimpleDateFormat("MM/dd/yy yy");
not for the date: 02/11/2013 I am getting in Excel: 5/29/94
09/10/ 2010 3/9/14
I changed the format to m/d/yy in my po style
In java se I assume it is SimpleDateFormat sf = new SimpleDateFormat("MM/dd/yy
not for the date: 02/11/2013 I am getting in Excel: 5/29/94
09/10/ 2010 3/9/14
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
actually, it is not an issue, I had logic error and it did not set the format I expected