[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

JExcel date format

Posted on 2007-03-22
4
Medium Priority
?
1,228 Views
Last Modified: 2008-01-09
Hi:

I am using JExcel to read data from an excel file published on the web and put it in our internal database. One of the columns in the file is date of format (mm/dd/2003). I do something like:
String theloaddate = null;
theloaddate = cell[0].getContents();
then I write "theloaddate" to a temporary csv file and bulk insert the file to a database table.

I got a SQLException as below:
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 289, column 1 (LoadDate).

I checked the temporary file and found the format of "theloaddate" column somehow got changed to dd/mm/yyyy which is fine, but I just can't see what's the problem with row 289. It looks exactly the same with any other rows.

Please help. Thanks.
0
Comment
Question by:sdc248
[X]
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
4 Comments
 

Author Comment

by:sdc248
ID: 18771199
ok, I see what's wrong with row 289 now.
That cell is 3/13/2003 (mm/dd/yyyy) but got changed to 13/03/2003 and SQL Server simply doesn't accept month 13. What should I do now?
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 1000 total points
ID: 18771732
DateFormat dfSource = new SimpleDateFormat("MM/dd/yyyy");
DateFormat dfTarget = new SimpleDateFormat("dd/MM/yyyy");
String theloaddate = dfTarget.format(dfSource.parse(cell[0].getContents()));

// Now you can load it
0
 

Author Comment

by:sdc248
ID: 18772328
In my case it's:
DateFormat dfSource = new SimpleDateFormat("dd/MM/yyyy");
DateFormat dfTarget = new SimpleDateFormat("MM/dd/yyyy");

but I got your point. And it's working. Thanks a lot.

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 18772568
:-)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

649 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