标签:ar sp on bs new nbsp res br ca
//取系统日期
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;
}
标签:ar sp on bs new nbsp res br ca
原文地址:http://www.cnblogs.com/qingshidaoren/p/4161074.html