title: Working with Dates in Spark
body: <p>I have a requirement where a CSV file is to be parsed, identify the records between the specific dates and find total and average sales for each sales person per ProductCategory in that duration. Below is the CSV file structure:</p>
  
  <p>SalesPersonId,SalesPersonName,SaleDate,SaleAmount,ProductCategory</p>
  
  <p>Please help in resolving this query. Looking for solution in Scala</p>
  
  <p>What I tried:</p>
  
  <p>Used the SimpleDateFormat as mentioned below:
  val format = new java.text.SimpleDateFormat("MM/dd/yyyy")
  and created an RDD with the below piece of code:
  val onlyHouseLoan = readFile.map(line => (line.split(",")(0), line.split(",")(2), line.split(",")(3).toLong, <strong>format.parse(line.split(",")(4).toString())</strong>))</p>
  
  <p>However, I tried using the Calendar on top of the highlighted expression but getting error that NumberformatExpression.</p>