学习安卓记录:day显示有误

package com.example.datetimepicker;

import java.util.Calendar;//是java的库
//以下是安卓的库
import android.app.Activity;
import android.os.Bundle;
import android.widget.DatePicker;
import android.widget.TimePicker;


public class MainActivity extends Activity {
    private TimePicker timePicker;//时间
    private DatePicker datePicker;//日历
    private Calendar cal;//也是日历
    private int year,month,day,hour,minute;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        //取得日历对象
        cal=Calendar.getInstance();
        //取得年月日的信息
        year=cal.get(Calendar.YEAR);
        month=cal.get(Calendar.MONTH)+1;//月份从0开始,在get括号外面加1;
        day=cal.get(Calendar.DAY_OF_MONTH);
        hour=cal.get(Calendar.HOUR_OF_DAY);
        minute=cal.get(Calendar.MINUTE);
        setTitle(year+"-"+month+"-"+day+"-"+hour+":"+minute);
    }


  

}


你可能感兴趣的:(学习安卓记录:day显示有误)