import java.text.SimpleDateFormat;
import java.util.Date;
public class TimeUtils {
/**
* @author Dminter
* @Mar 9, 2013 9:46:45 AM
* @TODO
* @param args
*/
public static void main(String[] args) {
Date as = new Date(new Date().getTime() - 24 * 60 * 60 * 1000);
SimpleDateFormat matter1 = new SimpleDateFormat("yyyy-MM-dd");
String time = matter1.format(as);
System.out.println(time);
System.out.println(getYesterdayDate());
System.out.println(dateToEDate(new Date()));
}
// 昨天
public static String getYesterdayDate() {
return new SimpleDateFormat("yyyy-MM-dd").format(new Date().getTime()
- 24 * 60 * 60 * 1000);
}
// 日期是周几
public static String dateToEDate(Date date) {
String eDate = "";
SimpleDateFormat dateFm = new SimpleDateFormat("EEEE");
eDate = dateFm.format(date);
return eDate;
}
// 当前日期
public static String getDate() {
return new SimpleDateFormat("yyyy-MM-dd").format(new Date());
}
// 日期格式
public static String getDateYDM() {
return new SimpleDateFormat("yyyyMMdd").format(new Date());
}
// 全时间
public static String getTime() {
return new SimpleDateFormat("yyyy-MM-dd HH:ss:mm").format(new Date());
}
}