1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- package com.fuzamei.utils;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- /**
- *
- * @author ylx
- * @describe: 用于生成相对路径的一个工具类
- */
- public class RelativePathUtil {
-
- private RelativePathUtil() {
- throw new AssertionError("不能实例化 RelativePathUtil");
- }
-
- /**
- *
- * @Title: formatPath
- * @Description: TODO(产生一个pattern格式的相对路径,用于拼接使用)
- * @param @param date
- * @param @param pattern
- * @param @return 设定文件
- * @return String 返回类型
- * @author ylx
- * @date 2017年12月29日 下午5:14:36
- * @throws
- */
- public static final String formatPath(final Date date, String pattern){
- if (date != null) {
- SimpleDateFormat dateformatter = new SimpleDateFormat(pattern);
- String dateString = dateformatter.format(date);
- return dateString;
- }
- throw new RuntimeException("date should not be null");
- }
-
- /**
- *
- * @Title: formatPath
- * @Description: TODO(相对路径格式为 /yyyy/MM/dd/HH/mm/ss/ )
- * @param @return 设定文件
- * @return String 返回类型
- * @author ylx
- * @date 2017年12月29日 下午5:19:26
- * @throws
- */
- public static final String formatPath(){
- return formatPath(new Date(),"/yyyy/MM/dd/HH/mm/ss/");
- }
-
- /**
- *
- * @Title: formatPath
- * @Description: TODO(根据需求传入默认路径的前缀和后缀)
- * @param @param prefix
- * @param @param sufix
- * @param @return 设定文件
- * @return String 返回类型
- * @author ylx
- * @date 2017年12月29日 下午5:38:51
- * @throws
- */
- public static final String formatPath(String prefix,String sufix){
- return prefix+formatPath()+sufix;
- }
-
- }
|