From JSpinner javadoc:
public Object getValue()
Returns the current value of the model, typically this value is displayed by the editor. If the user has changed the value displayed by the editor it is possible for the model's value to differ from that of the editor, refer to the class level javadoc for examples of how to deal with this.
This method simply delegates to the model. It is equivalent to:
getModel().getValue()
This means when you call getValue()
method you'll get a java.util.Date
object (since you're using SpinnerDateModel
I guess). When you use System.out.println(Spinner.getvalue())
the output shows the default toString()
implementation from java.util.Date
class which is long and includes the time.
If you want to show the date in this format yyyy/mm/dd
try this:
System.out.println(new SimpleDateFormat("yyyy/MM/dd").format(spinner.getValue()));
Note: don't get confused about java.util.Date
object and its String
representation.