• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ParseException involving SimpleDateFormat and Date

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

I posted this in another forum, no solution yet so thought of posting it here as well.

I have this set of code:


The above works fine when the value of startDate is in this format:"23-10-2014" However my startDate is in this format: "23/10/2014", and I am getting a: java.text.ParseException: Unparseable date: "23/10/2014".
exception.

Also I have tried using:

and I still get the java.text.ParseException: Unparseable date: "23/10/2014".
exception. How do I overcome this? Hope someone can help, thanks guys.
 
Greenhorn
Posts: 2
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

It seems there is no exception when the parsing is done as shown below,

String startDate = "23/10/2014";
SimpleDateFormat sParse = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
java.util.Date sDate = sParse.parse(startDate + " 00:00:00");

System.out.println("sDate-->"+sDate);

Is there any exact date format you are looking for?

Thanks
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post the full exception, including stack trace, because if that text was throwing an UnParseable exception I would expect it to say "23/10/2014 00:00:00", and not just show the date.
This implies to me that the line(s) you've shown are not the ones actually throwing the exception.
reply
    Bookmark Topic Watch Topic
  • New Topic