得到过去的时间:
example one:
private Date getDateTime(){
Calendar calendar = Calendar.getInstance();
calendar.set(2011, Calendar.DECEMBER, 1, 23, 0, 0);
return calendar.getTime();
}
example two:
String.valueOf(new Date().getTime() - 24 * 60 * 60 * 1000)
转换日期成String:
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public static String covertDate(Date d) {
String ret = "";
if (d != null) {
ret = sdf.format(d);
}
return ret;
}
标签:java,函数,getTime,ret,日期,Date,calendar,Calendar,String
From: https://blog.51cto.com/u_16261339/7468616