Exception in thread main java.time.format.DateTimeParseException: Text '31-Dec-13' could not be pa
生活随笔
收集整理的這篇文章主要介紹了
Exception in thread main java.time.format.DateTimeParseException: Text '31-Dec-13' could not be pa
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
完整報錯如下:
------------------------------看下lines----------------------------------- lines=Stream(Date,Open,High,Low,Close,Volume, ?) lines=Stream(31-Dec-13,114.61,117.13,114.46,116.12,12838233, ?) Exception in thread "main" java.time.format.DateTimeParseException: Text '31-Dec-13' could not be parsed at index 3at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949)at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)at java.time.LocalDate.parse(LocalDate.java:400)at RunRisk$$anonfun$readGoogleHistory$1.apply(RunRisk.scala:82)at RunRisk$$anonfun$readGoogleHistory$1.apply(RunRisk.scala:80)at scala.collection.immutable.Stream.map(Stream.scala:418)at RunRisk.readGoogleHistory(RunRisk.scala:80)at RunRisk$$anonfun$11.apply(RunRisk.scala:160)at RunRisk$$anonfun$11.apply(RunRisk.scala:160)at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)at scala.collection.mutable.ArrayOps$ofRef.map(ArrayOps.scala:186)at RunRisk.readStocksAndFactors(RunRisk.scala:160)at RunRisk$.main(RunRisk.scala:36)at RunRisk.main(RunRisk.scala)Process finished with exit code 1這里的index就是31-Dec-13里面的-
當(dāng)然了,理解index對于解決問題毫無幫助。
?
耗時很久,巨惡心,解決方案如下:
import java.time.format.DateTimeFormatter import java.util.Locale val formatter = DateTimeFormatter.ofPattern("d-MMM-yy",Locale.ENGLISH)環(huán)境為:
ubuntu18.10,amd64
jdk1.8.0_201
Intellij2018
?
總結(jié)
以上是生活随笔為你收集整理的Exception in thread main java.time.format.DateTimeParseException: Text '31-Dec-13' could not be pa的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: error: object Multiv
- 下一篇: java.lang.NoSuchMeth