/**
* 返回字符串的所有数字
* @param str
* @return
*/
def returnNumber(str: String): String = {
val regEx = "[^0-9]"
val p = Pattern.compile(regEx)
val m = p.matcher(str)
m.replaceAll("").trim
}
/**
*从中parquet文件中读取数据
*/
def readFromOdsParquet(sqlC:SQLContext, odsTableName:String): DataFrame = {
var frame:DataFrame = null
val filePath = PATH + File.separator + odsTableName
print(filePath)
sqlContext.read.parquet(filePath)
}
/**
* long型时间转为string
*/
def longTimeToString (time:Long)= {
val newtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
val strTime: String = newtime.format(time*1000)
val day_hour: Array[String] = strTime.split(" ")
(day_hour(0),day_hour(1))
}
/**
* String型时间转为Long
*/
def StringTimeToLong (time:String)= {
val newtime :Long= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(time).getTime
newtime/1000
}