apache poi  date format - xssf

Posted on 2014-02-07
Last Modified: 2014-02-19
I set up a format for my cel:
  DataFormat df = wb.createDataFormat();

style = createBorderedStyle(wb);
        styles.put("cell_pub_date", style);

Open in new window

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;

                        			try {

										java.util.Date date = sf.parse(date_s);

									catch (Exception e)	 {

										System.out.println( );	

Open in new window

but the date is comletely out of whack in my excel spreadhseet
Question by:sniger
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 16

Expert Comment

ID: 39843168
What do you mean "out of whack"? What does it look like after it ends up in Excel?
LVL 86

Accepted Solution

CEHJ earned 400 total points
ID: 39843189

Open in new window

I don't know this API, but, by the looks, getFormat gets a built-in format. afaics, there isn't such a built-in one:

Author Comment

ID: 39848624

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/yyyy");

not for the date:    02/11/2013  I am getting in Excel:    5/29/94
                                 09/10/ 2010                                         3/9/14
LVL 16

Assisted Solution

krakatoa earned 100 total points
ID: 39848844
Let us know if you heeded CEHJ's comment first, if you please.

BTW, 'D' and 'd' are different you realise.

Author Comment

ID: 39870598
actually, it is not an issue, I had logic error and it did not set the format I expected

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do I remove an object from a 3 63
Java array 21 150
Java array sort 10 63
maximize the sum of fractions 33 76
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question