Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date and Time entry

 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does Swing or AWT have a component for entering a date? I'm picturing a button that the user clicks that causes a calendar to popup. Then the user can choose the date.

Also is there something similar for time? Perhaps a JFormattedTextField will be sufficient for my needs here, but a "calendar picker" of some sort would be much more convenient for the date.

Thanks in advance.

Layne
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's something to play around with.
It's a bit rough - old code, I should clean it up (maybe one day)

 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I'll take a look at this code to see if it helps. I'm still wondering if Swing (or any other standard Java API) provides this functionality?
 
Dr Black
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a free calender program with a popup month calander that you can pick the date and it puts it in the date text field. Do a Google on 'java calendar examples'. If you use a database I have found that always storing the date as 'timestamp' solves lots of problems. Move the date around using java,util,Date keeps things neet and orderly. If you store the date as timestamp the same data can be shown on the screen as a date in one field and time in a different field using the Java 'simple.date.format' classes on the same timestamp field.

timestamp is ALWAYS stored as YYYMMDDhhmmssss even though you may specific fewer characters to the database.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your comments. Unfortunately (or perhaps fortunately), this program will deal with flat files for persistant storage.

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic