String fmt = "yyyyMM-dd";
SimpleDateFormat sdf = new SimpleDateFormat(fmt);
String dateStr = sdf.format(new Date());
调用tostring方法:
格式: 对象.tostring;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
format.format(date);