Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Sebastion Hill
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sebastion Hill
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob you are a wonderful person! :-) works!
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sebastion Hill wrote:Rob you are a wonderful person!

Well duh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic