You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
788 B

2 months ago
package com.project.logistics.domain.utils;
import cn.hutool.core.date.DateUtil;
2 months ago
import java.util.Calendar;
2 months ago
import java.util.Date;
public class FilePathUtil {
/**
* 生成层级路径: 2026年/2026年1月/2026年1月31日
*/
public static String getHierarchicalPath(Date date) {
2 months ago
// 使用Calendar类对日期进行减一天的操作
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(date);
// calendar.add(Calendar.DAY_OF_YEAR, 0);
// Date newDate = calendar.getTime();
2 months ago
String year = DateUtil.format(date, "yyyy年");
String month = DateUtil.format(date, "yyyy年M月");
String day = DateUtil.format(date, "yyyy年M月d日");
return year + "/" + month + "/" + day;
}
}