File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JCalendar problem" Watch "JCalendar problem" New topic
Author

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
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JCalendar problem
 
Similar Threads
date format in java
Java converting unix time to date different on each computer,why?
timezone on HP-UX.
Splitting a String
How to retrieve Date from JDBC using sql