• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Date and Time entry

 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your comments. Unfortunately (or perhaps fortunately), this program will deal with flat files for persistant storage.

Layne
 
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic