• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.text.ParseException: Unparseable date: "2012-08-03+05:30"

 
jaya kemmannu
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

The issue is regaring date to convert String into Date. Below is the code i used for conversion

Exception :

2012-09-04 18:47:11,182 ERROR [STDERR] Sep 4, 2012 6:47:11 PM [Plug-in standard error]: java.text.ParseException: Unparseable date: "2012-08-03+05:30"
2012-09-04 18:47:11,182 ERROR [STDERR] Sep 4, 2012 6:47:11 PM [Plug-in standard error]: at java.text.DateFormat.parse(DateFormat.java:335)

Java code :



Column Billdate and Duedate are of Type DATE in my oracle schema.

Regards,
Jaya
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What data type is "vPortOrderVO.getBilldate()"? How does it look if you print it? If it really looks like "2012-08-03+05:30", then -obviously- it doesn't match "dd-MMM-yy".
 
Winston Gutkowski
Bartender
Pie
Posts: 10277
60
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:What data type is "vPortOrderVO.getBilldate()"? How does it look if you print it? If it really looks like "2012-08-03+05:30", then -obviously- it doesn't match "dd-MMM-yy".

And BTW, that date string looks suspiciously like ISO 8601, except that I suspect it's missing both a time and a space. It should be:
"2012-08-03 12:30:00 +05:30"
not
"2012-08-03+05:30"
although this might be due to the format pattern that generated it.

A date with only a timezone doesn't make much sense.

Winston
 
jaya kemmannu
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi

getBilldate() and getDueDate() are of type String.When I receive SOAP XML that date format is <urn:BillDate>2012-08-11+05:30</urn:BillDate>. Below test code solved Parse Exception.



While updating the oracle table I use pstmt.setDate(10, vDate2) which is causing problem since vDate2 is of type String. How can i avoid this error.

Regards,
Jaya
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to:
- Convert your String to java.util.Date (do this as early as you can)
- Convert your java.util.Date to java.sql.Date
- Pass your java.sql.Date to setDate method
 
jaya kemmannu
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi James,

IS the below code OK ?


Regards,
Jaya
 
Winston Gutkowski
Bartender
Pie
Posts: 10277
60
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jaya kemmannu wrote:IS the below code OK ?

No. java.util.Date and java.sql.Date are closely related, and you've already parsed the Date, so just use:
java.sql.Date dt = new java.sql.Date(date.getTime());

[Edit]
Oh, and you don't need the:
Date date = new Date();
it's redundant. Just use:
Date date = (Date)formatter.parse(str_date);

Winston
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Further to Winston's comments, you also use two SimpleDateFormat instances when you could simply use one as the date format for both is the same.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic