我很新,想要将月份转换为字符串意味着从2015年6月12日到2015年6月12日来自Android DatePicker。无论我做什么,请帮助我如何改进我的代码..我是Android的新手。谢谢你们所有人提前
iCal.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
final Calendar c = Calendar.getInstance();
SimpleDateFormat month_date = new SimpleDateFormat("MMMM");
String month_name = month_date.format(c.getTime());
int year = c.get(Calendar.YEAR);
final int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
java.util.Date d = new java.util.Date(c.getTimeInMillis());
DatePickerDialog dp = new DatePickerDialog(CreateWardRobe.this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
SimpleDateFormat month_date = new SimpleDateFormat("MMMM");
String month_name = month_date.format(c.getTime());
String result ="";
String birth = "";
birth = String.valueOf(dayOfMonth);
birth += "." + String.valueOf(monthOfYear + 1);
birth += "." + year;
((TextView) iDoB).setText(birth);
new SimpleDateFormat("MMMM").format(result);
}
}, year, month, day);
dp.setIcon(R.drawable.birthday);
dp.setTitle("Birthday..");
dp.setMessage("Please Select Baby B'day");
dp.show();
}
});
答案 0 :(得分:0)
使用它。把它放在onDateSet方法
中 import java.text.DateFormatSymbols;
monthString = new DateFormatSymbols().getMonths()[month-1];
birth = date+"-"+dayOfMonth+"-"+year;
将出生值设置为textview