• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

String to Date conversion problem

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks!

I'm trying to convert the String "Fri Apr 2 17:43:22 2004" to a Date object.

Anyone knows how can I do that?
I already tried to use DateFormat.getDateInstance().parse(), but it throws a parse exception alerting that it is an unparseable date.

Thanks!
Joao
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See if you can create a DateFormat that matches your string format. I'm not up on date format enough to do it without some study. Lemme know what you find!
 
Joao Cunha
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried to create a SimpleDateFormat as follows:
SimpleDateFormat s = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy");
s.parse("Fri Sep 10 12:33:38 2004");

But it still throw Unparseable Date Exception.
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It works fine for me in the UK. Your default locale is set to foreign (non-English) parts. Try the following:

Jules
 
Joao Cunha
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With the Locale, it worked fine!

Thanks!
 
Willie Smits can speak 40 languages. This tiny ad can speak only one:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic