1
2
3
4
5
6
7
8
9
10
11
12
13
|
private
void
btn1Click()
//时间和日期
{
TimePicker timePicker = (TimePicker) findViewById(R.id.timePicker1);
int
hour = timePicker.getCurrentHour();
int
min = timePicker.getCurrentMinute();
DatePicker datePicker = (DatePicker) findViewById(R.id.datePicker1);
int
day = datePicker.getDayOfMonth();
int
month = datePicker.getMonth() +
1
;
//月份从0开始计算
int
year = datePicker.getYear();
TextView textView = (TextView) findViewById(R.id.textView1);
textView.setText(year +
"-"
+ month +
"-"
+ day +
" "
+ hour +
":"
+ min);
}
|
本文转自 glblong 51CTO博客,原文链接:http://blog.51cto.com/glblong/1200358,如需转载请自行联系原作者