import java.text.SimpleDateFormat;
import java.util.Date;
public class DateTool {
/**
* 获取当前日期,格式为:YYYYMMDD
* @return
*/
public static String getNowDate(){
String nowDate = "";
SimpleDateFormat dateFormat = null;
Date date = null;
date = new Date();
dateFormat = new SimpleDateFormat("yyyyMMdd");
nowDate = dateFormat.format(date).toString();
return nowDate;
}
/**
* 获取当前日期,格式为:指定格式
* @return
*/
public static String getNowDate(String format){
String nowDate = "";
SimpleDateFormat dateFormat = null;
Date date = null;
date = new Date();
dateFormat = new SimpleDateFormat(format);
nowDate = dateFormat.format(date).toString();
return nowDate;
}
/**
* 获取当前日期,格式为:yyyyMMddhhmmss
* @return
*/
public static String getNowDateTime(){
String nowDateTime = "";
SimpleDateFormat dateFormat = null;
Date date = null;
date = new Date();
dateFormat = new SimpleDateFormat("yyyyMMddhhmmss");
nowDateTime = dateFormat.format(date).toString();
return nowDateTime;
}
/**
* 获取当前日期,格式为:指定格式
* @return
*/
public static String getNowDateTime(String format){
String nowDateTime = "";
SimpleDateFormat dateFormat = null;
Date date = null;
date = new Date();
dateFormat = new SimpleDateFormat(format);
nowDateTime = dateFormat.format(date).toString();
return nowDateTime;
}
}
04-13
9385
01-22
1015