• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

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

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi James,

IS the below code OK ?


Regards,
Jaya
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Did Steve tell you that? Fuh - Steve. Just look at this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic