• Post Reply Bookmark Topic Watch Topic
  • New Topic

Date Format

 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • 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 ]
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thank You.
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
You could parse in multiple formats and display it in 1 format.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!