Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个自定义类,其中包含 JodaTime 的 LocalDate 变量来保存日期。我的摇摆应用程序有一个带有日期模型的 JSpinner。我制作了一个按钮单击事件,以便将日期存储在对象的 LocalDate 数据成员中。问题是编译器给了我 IllegalArgumentException。
我尝试使用 LocalDate.parse(spinnerDate.getVALue().toString()) 但不工作。还尝试切换到使用 DateTime 类型,但给出了相同的结果。
鉴于 an是在运行时IllegalArgumentException生成的东西,我怀疑你得到了一个“编译器”错误。
IllegalArgumentException
如果您不关心时区或年表(可能),您可以随时使用new LocalDate(spinnerDate.getValue());.
new LocalDate(spinnerDate.getValue());
否则,请考虑实现您自己的可以本地存储LocalDates 的微调器,或者切换到在 a 中使用预定义的LocalDates列表SpinnerListModel。
LocalDate
SpinnerListModel