ylx 7 anos atrás
pai
commit
e18292bbbb

+ 68 - 0
ccb_fund_trusteeship/src/main/java/com/fuzamei/utils/RelativePathUtil.java

@@ -0,0 +1,68 @@
+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 formatPath(new Date(),prefix+"/yyyy/MM/dd/HH/mm/ss/"+sufix);
+	}
+	
+}