![JAR search and dependency download from the Maven repository](/logo.png)
fun.tusi.converter.String2LocalDateTimeConverter Maven / Gradle / Ivy
package fun.tusi.converter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
/**
* String类型时间戳格式参数 -> 接收对象中的 LocalDateTime
* @author xy783
*/
@Slf4j
public class String2LocalDateTimeConverter implements Converter {
@Override
public LocalDateTime convert(String timestampStr) {
// 秒级时间戳 转 LocalDateTime
return StringUtils.hasText(timestampStr)?Instant.ofEpochSecond(Long.parseLong(timestampStr)).atZone(ZoneOffset.of("+8")).toLocalDateTime():null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy