我正在嘗試使用對(duì)象輸出流將數(shù)組列表中的所有對(duì)象保存到文件中。該對(duì)象的一個(gè)屬性是本地日期,每當(dāng)我嘗試寫(xiě)入文件時(shí),錯(cuò)誤不可序列化異常:java.time.format.DateTime 格式化器返回,盡管沒(méi)有任何本地日期的日期時(shí)間格式化程序完整錯(cuò)誤:java.io.NotSerializableException: java.time.format.DateTimeFormatter at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1185) at java.base/java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1553) at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1510) at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1433) at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1179) at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:349) at java.base/java.util.ArrayList.writeObject(ArrayList.java:791) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at java.base/java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1130) at java.base/java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1497) at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1433) at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1179) at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:349) at BikeNow.saveRent(BikeNow.java:330) at BikeNow.main(BikeNow.java:114)
如何修復(fù)“不可序列化異常:java.時(shí)間.格式.日期時(shí)間格式化程序”錯(cuò)誤
開(kāi)心每一天1111
2022-09-28 15:40:16