问什么我的时间和系统的时间差了整整4小时呢。分钟数正确就小时数有问题。下面是代码。我只添加啦time'picker
package com.example.administrator.time1;
import android.icu.util.Calendar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TimePicker;
public class MainActivity extends AppCompatActivity {
private TimePicker tinepicker;
private Calendar cal;
private int hour;
private int minute;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
cal = Calendar.getInstance();
hour= cal.get(Calendar.HOUR_OF_DAY);
minute = cal.get(Calendar.MINUTE);
setTitle(hour+":"+minute);
}
}