Two Laptop Bag*
The moose likes Java in General and the fly likes java.text.ParseException: Unparseable date: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java.text.ParseException: Unparseable date: "2012-08-03+05:30"" Watch "java.text.ParseException: Unparseable date: "2012-08-03+05:30"" New topic
Author

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

jaya kemmannu
Ranch Hand

Joined: Sep 23, 2011
Posts: 85

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
Marshal

Joined: Mar 22, 2005
Posts: 42365
    
  64
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".


Ping & DNS - my free Android networking tools app
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8043
    
  22

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


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
jaya kemmannu
Ranch Hand

Joined: Sep 23, 2011
Posts: 85

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

Joined: Nov 09, 2011
Posts: 1030
    
    5

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

Joined: Sep 23, 2011
Posts: 85

Hi James,

IS the below code OK ?


Regards,
Jaya
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8043
    
  22

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

Joined: Nov 09, 2011
Posts: 1030
    
    5

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.text.ParseException: Unparseable date: "2012-08-03+05:30"