• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Date Format

 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. I just recently purchased a JavaBean that is a DatePicker. I have it set up so that when a user picks on a date, it transfers that date to a JTextField. My only issue with this is it transfers the date in this format:
Mon May 06 18:42:21 CDT 2002
What is the easiest way to get this into a Date format(mm/dd/yyyy) so I can save it to a SQL table?
Right now, to get the value, the getNewValue() method is being used on a PropertyChangeEvent.
Can I convert it before it is saved, or do I do it when the date is transferred?
FYI: I didn't purchase the source($500 yikes!) for the JavaBean so I don't have that.
Thanks for any help!!
[ May 06, 2002: Message edited by: Jennifer Sohl ]
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SimpleDateFormat. Do a search in the beginner forum or look at the API. It isn't very difficult to use.
Good Luck.
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You.
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello. Me again. I think I have a pretty good idea how the SimpleDateFormat class works now.
Now I have another issue that I'm not really sure how to approach. I was wondering if someone could give me a hint.
Right now I have a JTextField that formats a date like this when it is displayed:
Friday May 10, 2002
I want to keep this format for when I am retrieving dates from a table, however, I want the user to be able to key in a date like this:
5/10/02.
I can't do that right now, because it won't parse the date if they key it in this way.
Does anyone have any bright ideas?
Thanks again for your help!
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could parse in multiple formats and display it in 1 format.
 
A wop bop a lu bob a womp bam boom. Tutti frutti ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic