private String year; //年
private String month; //月
private String day; //日
/**
*
*@描述:返回当前中文日期 二○一八年十月三十日
*@创建人:kwy
*@创建时间:2018-12-03 下午01:52:56
*@修改人:
*@修改时间:
*@修改描述:
*@return
*/
public String getDate(){
StringBuffer datebuffer = new StringBuffer();
datebuffer.append(year);
datebuffer.append("年");
if(null==month){
month = "1";
}
String monthStr ="";
if(Integer.parseInt(month)>9){
if("11".equals(month)){
monthStr="十一";
}else {
monthStr = month.replace("1", "十").replaceAll("0", "");
}
datebuffer.append(monthStr);
}else{
datebuffer.append(month);
}
datebuffer.append("月");
if(null==day){
day = "1";
}
int intday = Integer.parseInt(day);
if(intday>9){
String dayStr = String.valueOf(intday/10).replace("1", "十")
.replace("2", "二十")
.replace("3", "三十")+String.valueOf(intday%10);
datebuffer.append(dayStr.replaceAll("0", ""));
}else{
datebuffer.append(day);
}
datebuffer.append("日");
String date = datebuffer.toString().replaceAll("1", "一")
.replaceAll("2", "二")
.replaceAll("3", "三")
.replaceAll("4", "四")
.replaceAll("5", "五")
.replaceAll("6", "六")
.replaceAll("7", "七")
.replaceAll("8", "八")
.replaceAll("9", "九")
.replaceAll("0", "○");
return date;
}
另一种
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 currentTime = year + "年"+month+"月"+day+"日";