• 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

JCalendar problem

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If anyone here is familiar with JCalendar from toedter, i need some help. I created the component "d" of type JDateChooser, I set the information to be displayed in it to be like this: d.setDateFormatString("dd.MM.yyyy"); the problem is that it displays the date in this form only in the textfield, after i chose the date. In my program, if I try to get the date like this: d.getDate() it returns something like this: Thu Apr 19 17:02:50 EEST 2012. The question is: what can I do to get the date from d in the form dd.MM.yyyy?
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use a (Simple)DateFormat object. That's probably what the JDateChooser uses internally as well.
The thing is, Date objects don't really have a format. It just contains a moment in time. It does have a format from toString(), but that's more meant for debugging purposes. For anything else a DateFormat is the way to go, as it gives you control over how you want to format the Date.
 
Water proof donuts! Eat them while reading this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic