Bob
Bob

Reputation: 1375

How to store value from JSpinner of Date format into a JodaTime variable?

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.

Upvotes: 0

Views: 828

Answers (1)

Clockwork-Muse
Clockwork-Muse

Reputation: 13056

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.

Upvotes: 1

Related Questions