Exception in thread "main" java.time.format.DateTimeParseException: Text '31-Dec-13' could not be pa

完整报错如下:

------------------------------看下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 3
	at 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里面的-

当然了,理解index对于解决问题毫无帮助。

 

耗时很久,巨恶心,解决方案如下:

import java.time.format.DateTimeFormatter
import java.util.Locale
val formatter = DateTimeFormatter.ofPattern("d-MMM-yy",Locale.ENGLISH)

环境为:

ubuntu18.10,amd64

jdk1.8.0_201

Intellij2018

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值