//取系统日期
public String getDateWithString() {
Calendar now = Calendar.getInstance();
int month = now.get(Calendar.MONTH) + 1;
int day = now.get(Calendar.DAY_OF_MONTH);
int year = now.get(Calendar.YEAR);
String result = year + " 年 " + month + " 月 " + day + " 日 ";
return result;
}
//取系统日期
public String getDateWithYMD() {
Calendar now = Calendar.getInstance();
int month = now.get(Calendar.MONTH) + 1;
int day = now.get(Calendar.DAY_OF_MONTH);
int year = now.get(Calendar.YEAR);
String date = year + "-" + month + "-" + day;
return date;
}
//取系统日期
public String getDateWithNum() {
Calendar now = Calendar.getInstance();
int year = now.get(Calendar.YEAR);
int month = now.get(Calendar.MONTH) + 1;
int day = now.get(Calendar.DAY_OF_MONTH);
String smonth = "" + month;
String sday = "" + day;
if (month < 10) {
smonth = "0" + month;
}
if (day < 10) {
sday = "0" + day;
}
String date = year + smonth + sday;
return date;
}
//取系统日期
public Date getDate() {
Calendar now = Calendar.getInstance();
int month = now.get(Calendar.MONTH) + 1;
int day = now.get(Calendar.DAY_OF_MONTH);
int year = now.get(Calendar.YEAR);
String date = year + "-" + month + "-" + day;
Date result = Date.valueOf(date);
return result;
}