timestamp 与 calendar 等时间格式处理

timestamp 格式  加减 天月等;

def subStractOneYear(time:TimeStamp): TimeStamp =  {

val calendar = Calendar.getInstance()

calendar.setTimeInMillis(time.getTime)

calendar.add(Calendar.YEAR,-1)

new TimeStamp(calendar.getTimeInMillis)

}


判断时间日期是否在一个范围内:

caseclassDateRange(startDate:Timestamp, endDate:Timestamp) {

defin(targetDate:Date):Boolean={

targetDate.before(endDate)

&& targetDate.after(startDate)

}

}

你可能感兴趣的:(timestamp 与 calendar 等时间格式处理)