Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Parsing date exception  RSS feed

 
Thaiyalnayaki Kathiresan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

When I am running this code, it calls the readCSV class



And I am getting the parse date exception. I am new to java. I just want to learn certain things.... Thanks in advance for the help
The error which I am getting is


 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16026
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

That's a lot of code to wade through!

It looks like your program is expecting a date in the format "yyyy-MM-dd" (4 digits year, a '-' character, 2 digits month, a '-' character and 2 digits day) because that's what you specified when making the SimpleDateFormat object.

A date like "8/4/1955" does not look like the format "yyyy-MM-dd". It should have been "1955-04-08". Or you should have specified a different format when creating the SimpleDateFormat object, for example "dd/MM/yyyy". (Is it month/day or day/month?).
 
Liutauras Vilda
Marshal
Posts: 4634
316
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thaiyalnayaki Kathiresan, welcome to the Ranch.

Please UseCodeTags (<-- link) when you posting code, in that way it is much easier to read it.
I have added them for you this time, see how better it looks?
 
Campbell Ritchie
Marshal
Posts: 55681
162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again

Why are you writing your own CSV parser when there are parsing libraries available and you can use factory methods like this one or this one? What does epoch++ mean on line 169?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!