时间格式转化成string工具类:
package cn.javass.util; import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date; public class DateFormatUtil {
private DateFormatUtil(){} public enum DateFormatStyleEnum{
YMD("yyyy-MM-dd"),YMDHMS("yyyy-MM-dd HH:mm:ss");
private String str = "";
private DateFormatStyleEnum(String str){
this.str = str;
}
public String getStr(){
return this.str;
} }
public static String data2Str(DateFormatStyleEnum dfStyle,long time){
DateFormat df = new SimpleDateFormat(dfStyle.getStr());
return df.format(new Date(time));
}
}