This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Date and Time entry Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Date and Time entry" Watch "Date and Time entry" New topic
Author

Date and Time entry

Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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


Java API Documentation
The Java Tutorial
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Dec 06, 2001
Posts: 3061
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

Joined: Sep 12, 2003
Posts: 1
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.


Background<br />Linux, MySQL, Zaurus, COBOL, etc.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Thanks for your comments. Unfortunately (or perhaps fortunately), this program will deal with flat files for persistant storage.

Layne
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date and Time entry
 
Similar Threads
How to manipulate date / time using Calendar and then put the modified data inside the Date class?
Time between two time values
calendar to date and timezone
Reading date from Oracle based on calendar
Java Swing Date & Time Picker Component