| 12345678910111213141516171819202122232425 |
- package com.persagy.iot.utils
- import java.text.SimpleDateFormat
- object IOTUtils {
- /**
- * 将时间字段转换成时间戳
- * @param dateStr 时间字段
- * @param formatPattern 要转换时间字段的格式
- * @param offer 时差(单位:毫秒)
- * @return
- */
- def timestampConverter(formatPattern: String, dateStr: String, offer: Long): Long ={
- val simpleDateFormat = new SimpleDateFormat(formatPattern)
- val timestamp = simpleDateFormat.parse(dateStr).getTime
- timestamp + offer
- }
- /**
- * 获取当前时间
- * @return
- */
- def now(): Long = {System.currentTimeMillis ()}
- }
|