package com.vincent.rsf.server.api.utils; import java.util.Date; public class TimeConverterUtils { /** * 秒级时间戳转Date */ public Date timestampToDate(Long timestamp) { if (timestamp == null) { return null; } return new Date(timestamp * 1000); } /** * Date转秒级时间戳 */ public Long dateToTimestamp(Date date) { if (date == null) { return null; } return date.getTime() / 1000; } /** * 毫秒级时间戳转Date */ public Date millisToDate(Long millis) { if (millis == null) { return null; } return new Date(millis); } /** * Date转毫秒级时间戳 */ public Long dateToMillis(Date date) { if (date == null) { return null; } return date.getTime(); } }