Inorder to get it done first you need to import calender
First you need some imports:
import java.util.Calendar
import java.text.SimpleDateFormat
import java.util.Date
val now = Calendar.getInstance().getTime() //you can get the current Time:
val formatter = new SimpleDateFormat("MM-dd-yyyy")
val dateAsString = formatter.format(now) //use your formatter to get the date as String
Then you can load your resource with the dateAsString value using String interpolation:
val fileFromS3= sc.textFile(s"s3a://digital/${dateAsString}/abc.csv")
Hope this helps!
If you want to know more about Apache Spark Scala, It's highly recommended to go for Spark certification course today.
Thanks!!