Get current date as string in databricks using scala

Vibhor
Contributor

I want to get current date in scala as a string for example today current date is 3rd jan, want to store it as a new variable dynamically as below, how to get it.

val currdate : String = “20220103”

when I am using val currdate = Calendar.getInstance.getTime then am not getting output in desired format as above.