androidのDatePickerで10未満の月または日を選択した場合に先頭に0を付けたいのですがそのような方法はありますでしょうか。
ソースは以下のようになっております。
final TextView text = (TextView) findViewById(R.id.calender);
//カレンダを生成
Calendar _calendar = Calendar.getInstance();
DatePickerDialog _datePickerDialog = new DatePickerDialog(
this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
text.setText(year + "年" + monthOfYear + "月"+dayOfMonth+"日");
}
},
_calendar.get(Calendar.YEAR),
_calendar.get(Calendar.MONTH),
_calendar.get(Calendar.DAY_OF_MONTH)
);
_datePickerDialog.show(); }
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。