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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping2 challenge 13 80
Running Jira on Raspberry PI 2? 3 246
advertisement module in core php 4 144
Java and GPO 11 66
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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 will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

929 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now