public class DateUtil {
public static final String DATE_FORMAT_YYYY = "yyyy";
public static final String DATE_FORMAT_MM = "MM";
public static final String DATE_FORMAT_YYYYMMDD = "yyyyMMdd";
public static final String DATE_FORMAT_YYYY_MM_DD = "yyyy/MM/dd";
public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
public static final String DEFAULT_MONTH_FORMAT = "yyyy-MM";
public static final String DEFAULT_TIME_FORMAT = "HH:mm:ss";
public static final String DEFAULT_MONTH = "MONTH";
public static final String DEFAULT_YEAR = "YEAR";
public static final String DEFAULT_DATE = "DAY";
public static final String DEFAULT_HOUR = "HOUR";
public static final String DEFAULT_MINUTE = "MINUTE";
public static final String DEFAULT_SECOND = "SECOND";
public static final String DEFAULT_DATETIME_FORMAT_HH = "yyyy-MM-dd HH";
public static final String DEFAULT_DATETIME_FORMAT = "yyyy-MM-dd HH-mm";
public static final String DEFAULT_DATETIME_FORMAT_SEC = "yyyy-MM-dd HH:mm:ss";
public static final String DEFAULT_DATETIME_FORMAT_MIN = "yyyy-MM-dd HH:mm";
public static final String DEFAULT_DATETIME_FORMAT_S = "yyyyMMddHHmmss";
public static LocalDateTime getCurrentTime(){
SimpleDateFormat sdf=new SimpleDateFormat(DEFAULT_DATETIME_FORMAT_SEC);
String strDate=sdf.format(System.currentTimeMillis());
DateTimeFormatter df = DateTimeFormatter.ofPattern(DEFAULT_DATETIME_FORMAT_SEC);
return LocalDateTime.parse(strDate, df);
}
}
|