Take the 2-minute tour ×

I got a custom class that contains JodaTime's LocalDate variable to hold a date. My swing application has a JSpinner with Date model. I made a button click event so that the date gets stored inside an object's LocalDate data member. Problem is compiler gives me the IllegalArgumentException.

I tried to use LocalDate.parse(spinnerDate.getVAlue().toString()) but is not working. Also tried to switch to using DateTime type but same result was given.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Given that an IllegalArgumentException is something that would be generated at runtime, I doubt you're getting a 'compiler' error.

If you don't care what the timezone or chronology is (probable), you could always use new LocalDate(spinnerDate.getValue());.

Otherwise, consider implementing your own spinner that can store LocalDates natively, or switching to using a pre-defined list of LocalDates in a SpinnerListModel.

share|improve this answer
Hmm. The new LocalDate(spinnerDate.getValue()); worked. I guess .toString was the one causing the runtime error. Thanks! –  Bob Feb 10 '12 at 17:50
You'd probably need to run through an entire formatter to get the string version to work - the LocalDate will be expecting a particular format. But that's not necessary here - you have a valid date object to begin with. –  Clockwork-Muse Feb 10 '12 at 18:35
add comment

Your Answer


