1.
For Scala, we can import datetime package from java libraries.
For JAVA 8 + ,
Import the date object and formatter that is
java.time.LocalDate
and
java.time.format.DateTimeFormatter
then, parse the string to date
LocalDate.parse(“[date]”,DateTimeFormatter.ofPattern("MM/dd/yyyy"))
then format the date to string,
date.format(DateTimeFormatter.ofPattern("[preferred format]"))
NOTE : By default, the ISO format is followed which is YYYY-MM-DD
For JAVA 7,
Use SimpleDateFormat to define format,
val originFormat = new SimpleDateFormat("[initial format]")
val targetFormat = new SimpleDateFormat("[required format]")
targetFormat.format(originFormat.parse("[data]"))
2.
For price column, you can use float or double data type
Float
32 bit IEEE 754 single-precision float
Double
64 bit IEEE 754 double-precision float
Enroll in the Scala course in Singapore to get professionally certified.