Java生成当日日期 时间 生成当前日期时间 //当前日期时间方法 string类型 public static String newDateTime(){ SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String datetime = tempDate.format(ne
Java生成当日日期 时间
生成当前日期时间
//当前日期时间方法 string类型 public static String newDateTime(){ SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String datetime = tempDate.format(new java.util.Date()); return datetime; }生成昨日日期
//生成昨日的日期 public static String newYesterdayDate(){ DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar=Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY,-24); String yesterdayDate=dateFormat.format(calendar.getTime()); return yesterdayDate; }