Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hii,everybody i am creating a gui where i need a timepicker i got Jspinner but the issue i want to convert the jspinner value into a string when i am doing it ,i am getting this exception (
java.lang.ClassCastException: class java.util.Date cannot be cast to class java.lang.String (java.util.Date and java.lang.String are in module java.base of loader 'bootstrap')

What I have tried:

this is the code

      <pre> timeSpinner = new JSpinner( new SpinnerDateModel() );
        timeEditor = new JSpinner.DateEditor(timeSpinner, "HH:mm");
        timeSpinner.setEditor(timeEditor);
        timeSpinner.setBounds(330,100,100,30);
        timeSpinner.setFont(f5);
        panel.add(timeSpinner);


String ts1= 
         (timeEditor.getFormat().format(timeSpinner.getValue())).toString();
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900