java - ParseException: Unparseable date error trying to parse a date from csv (windows) -


i have program parsing csv file , use actions based on csv data each line.

the funny thing is, on mac program run , use run on windows well, reason when run on windows error:

java.text.parseexception: unparseable date: "27-nov-14" @ java.text.dateformat.parse(unknown source) ~[na:1.8.0_60] @ controllers.purchaseinfo$.controllers$purchaseinfo$$changedateformat( purchaseinfo.scala:44) ~[play-scala.play-scala-1.1%20snapshot-sans-externalized. jar:na]

there no different in date format. didnt changes dont have idea why there error.

this purchaseinfo func formatting date:

private def changedateformat(dateinstring: string): string = {   //system.out.println(dateinstring)   //val formatter: simpledateformat = new simpledateformat("mmm dd, yyyy")   val formatter: simpledateformat = new simpledateformat("dd-mmm-yy")   val formatter2: simpledateformat = new simpledateformat("dd/mm/yyyy")   val date: date = formatter.parse(dateinstring)   return formatter2.format(date).tostring 

please help, let me know pieces of code need understand more...

ensure windows machine has english locale.

you can specify locale in simpledateformat constructor avoid kind of problems:

val formatter: simpledateformat = new simpledateformat("yyyy-mm-dd", locale.english); 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -