File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Help please, using a JSpinner but I can't get the user's input into a date object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Help please, using a JSpinner but I can Watch "Help please, using a JSpinner but I can New topic
Author

Help please, using a JSpinner but I can't get the user's input into a date object

Sebastion Hill
Ranch Hand

Joined: Jul 10, 2009
Posts: 48
So I have my GUI set up to allow a user to pick a date using the JSpinner with the following code:


I have this as an inner class for when the user presses a button after entering in the date info he/she wants. This is just a test right now, but I can't find a way to get the date on the JSpinner into one easy date object. Do I need to use the spinner and turn it into a string, then parse the string? Or is there an easier, more efficient method, that I am overlooking? :-(

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

Just use getValue() and cast it to Date. JSpinner's getValue() method simply returns getModel().getValue(); for SpinnerDateModel, both getValue() and getDate() return the same value.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Sebastion Hill
Ranch Hand

Joined: Jul 10, 2009
Posts: 48
Rob you are a wonderful person! :-) works!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

Sebastion Hill wrote:Rob you are a wonderful person!

Well duh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help please, using a JSpinner but I can't get the user's input into a date object