大屏项目初始化
This commit is contained in:
39
src/main/java/com/mini/mybigscreen/utils/DateUtils.java
Normal file
39
src/main/java/com/mini/mybigscreen/utils/DateUtils.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package com.mini.mybigscreen.utils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class DateUtils {
|
||||
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
private static final DateTimeFormatter YEAR_FORMATTER = DateTimeFormatter.ofPattern("yyyy");
|
||||
private static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("MM");
|
||||
|
||||
public static String dsValue() {
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
return currentDate.format(DATE_FORMATTER);
|
||||
}
|
||||
|
||||
public static String dsValueDaysAgo(long days) {
|
||||
LocalDate targetDate = LocalDate.now().minusDays(days);
|
||||
return targetDate.format(DATE_FORMATTER);
|
||||
}
|
||||
|
||||
public static String getCurrentYear() {
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
return currentDate.format(YEAR_FORMATTER);
|
||||
}
|
||||
|
||||
public static String getCurrentMonth() {
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
return currentDate.format(MONTH_FORMATTER);
|
||||
}
|
||||
|
||||
public static String getYear(LocalDate date) {
|
||||
return date.format(YEAR_FORMATTER);
|
||||
}
|
||||
|
||||
public static String getMonth(LocalDate date) {
|
||||
return date.format(MONTH_FORMATTER);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user