This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes JCalendar problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JCalendar problem" Watch "JCalendar problem" New topic

JCalendar problem

Rus Corina
Ranch Hand

Joined: Jul 08, 2011
Posts: 90
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?
Rob Spoor

Joined: Oct 27, 2005
Posts: 19674

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.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: JCalendar problem