/**
* 获取实时时间
* @return
*/
public String nowDate() {
Date day = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String today = sdf.format(day);
return today;
}
/**
* 转换时间 09:45:00
* @param str
* @return
*/
public static Date strToDate(String str) {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
Date date = null;
try {
date = sdf.parse(str);
} catch (ParseException e) {
}
return date;
}
/**
* 日期转字符串
* @param date
* @return
*/
public static String DateToString(Date date) {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
String string = sdf.format(date);
return string;
}
public static String DateToString2(Date date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String string = sdf.format(date);
return string;
}
网友评论