初始化项目
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package com.jeesite.modules.utils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
|
||||
public class DateUtils {
|
||||
private static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("MM");
|
||||
@@ -12,7 +15,6 @@ public class DateUtils {
|
||||
private static final DateTimeFormatter SHORT_YEAR_MONTH_CN_FORMATTER = DateTimeFormatter.ofPattern("yy年MM月");
|
||||
|
||||
|
||||
|
||||
public static String dsValue() {
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
return currentDate.format(DATE_FORMATTER);
|
||||
@@ -50,4 +52,20 @@ public class DateUtils {
|
||||
public static String getMonth(LocalDate date) {
|
||||
return date.format(MONTH_FORMATTER);
|
||||
}
|
||||
|
||||
public static String getYear(Date date) {
|
||||
return getYear(dateToLocalDate(date));
|
||||
}
|
||||
|
||||
public static String getMonth(Date date) {
|
||||
return getMonth(dateToLocalDate(date));
|
||||
}
|
||||
|
||||
public static String getDate(String pattern) {
|
||||
return new SimpleDateFormat(pattern).format(new Date());
|
||||
}
|
||||
|
||||
public static LocalDate dateToLocalDate(Date date) {
|
||||
return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user