com.treeyh.raindrop.utils.DateUtils Maven / Gradle / Ivy
The newest version!
package com.treeyh.raindrop.utils;
import lombok.extern.slf4j.Slf4j;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @author: Treeyh
* @version: 1.0
* @description:
* @create: 2023-04-06 17:58
* @email: [email protected]
**/
@Slf4j
public class DateUtils {
public static Date str2Date(String val) {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = sdf1.parse(val);
}catch (Exception e){
log.error("str2Date error. "+ e.getMessage(), e);
}
return date;
}
public static String date2Str(Date date) {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf1.format(date);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy