java对时间格式化

import java.sql.Date;
import java.text.SimpleDateFormat;


public class UtilTimeFormatter {
	private static final SimpleDateFormat dateymd = new SimpleDateFormat("yyyy-MM-dd");
	private static final SimpleDateFormat dateymdCN = new SimpleDateFormat("yyyy年MM月dd日");
	private static final SimpleDateFormat dateymdhms = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	private static final SimpleDateFormat dateymdhmsCN = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
	
	
	public static String getTimeToYMD(long date){
		String time = dateymd.format(new Date(date));
		return time;
	}
	public static String getTimeToYMD(Date date){
		String time = dateymd.format(date);
		return time;
	}
	public static String getTimeToYMDHMS(long date){
		String time = dateymdhms.format(new Date(date));
		return time;
	}
	public static String getTimeToYMDHMS(Date date){
		String time = dateymdhms.format(date);
		return time;
	}
	public static String getTimeToYMDHMSCN(long date){
		String time = dateymdhmsCN.format(new Date(date));
		return time;
	}
	public static String getTimeToYMDHMSCN(Date date){
		String time = dateymdhmsCN.format(date);
		return time;
	}
	public static String getTimeToYMDCN(long date){
		String time = dateymdCN.format(new Date(date));
		return time;
	}
	public static String getTimeToYMDCN(Date date){
		String time = dateymdCN.format(date);
		return time;
	}
}
 

你可能感兴趣的:(java,sql)