After the date_format, you can convert it into anonymous Dataset and just use first function to get that into a string variable. Check this out
scala> val dateFormat = "yyyyMMdd_HHmm"
dateFormat: String = yyyyMMdd_HHmm
scala> val dateValue = spark.range(1).select(date_format(current_timestamp,dateFormat)).as[(String)].first
dateValue: String = 20190320_2341
scala> val fileName = "TestFile_" + dateValue+ ".csv"
fileName: String = TestFile_20190320_2341.csv
scala>
Without creating df, you can use expr() and get the results.
scala> val ts = (current_timestamp()).expr.eval().toString.toLong
ts: Long = 1553106289387000
scala> new java.sql.Timestamp(ts/1000)
res74: java.sql.Timestamp = 2019-03-20 23:54:49.387
The above gives the result in normal scala, so you can format using date/time libraries
EDIT1:
Here is one more way, with the formatting in normal scala.
scala> val dateFormat = "yyyyMMdd_HHmm"
dateFormat: String = yyyyMMdd_HHmm
scala> val ts = (current_timestamp()).expr.eval().toString.toLong
ts: Long = 1553108012089000
scala> val dateValue = new java.sql.Timestamp(ts/1000).toLocalDateTime.format(java.time.format.DateTimeFormatter.ofPattern(dateFormat))
dateValue: String = 20190321_0023
scala> val fileName = "TestFile_" + dateValue+ ".csv"
fileName: String = TestFile_20190321_0023.csv
scala>
Using pyspark
>>> dateFormat = "%Y%m%d_%H%M"
>>> import datetime
>>> ts=spark.sql(""" select current_timestamp() as ctime """).collect()[0]["ctime"]
>>> ts.strftime(dateFormat)
'20190328_1332'
>>> "TestFile_" +ts.strftime(dateFormat) + ".csv"
'TestFile_20190328_1332.csv'
>>>