defgetNowDate():String={
var now = new Date()
var dateFormat = new SimpleDateFormat("yyyy-MM-dd")
var today = dateFormat.format( now )
today
}
获取以前的日期
defgetPreday(days:Int):String= {
val dateFormat = new SimpleDateFormat("yyyy-MM-dd")
val cal = Calendar.getInstance()
cal.setTime(new Date())
cal.add(Calendar.DATE, -days)
var pre_days = dateFormat.format(cal.getTime())
pre_days
}
日期转换:2018-07-03 转换为20180703
start_date.toString.replace("-", "")
数据字段格式转换
result = result.withColumn("MAX_DEC",col("MAX_DEC").cast("Int"))
获取当前日期 def getNowDate():String={ var now = new Date() var dateFormat = new SimpleDateFormat("yyyy-MM-dd") var today = dateFormat.format( now ) today }获取以前的日期 def getPreda...