Problems using SimpleDateFormat

前端 未结 4 1104
死守一世寂寞
死守一世寂寞 2021-01-21 08:20

Apparently, I\'m missing something fundamental. I\'m having a problem with formatting the value of a jspinner. I\'ve tried a couple different ways and keep receiving an error, d

4条回答
  •  长发绾君心
    2021-01-21 08:56

    I suspect it's because your JSpinner#getValue() method is returning a Date and you don't need to parse it. You might try replacing with just

    Date from = (Date) dateFrom.getValue();
    

    Calling Date.toString() always returns a date in the same default format for the current locale ("Mon Oct 23 00:00:00 ...") which is why you're getting an exception on trying to parse it.

提交回复
热议问题