TimeZone tx = TimeZone.getTimeZone("Asia/Tokyo");
Calendar d = Calendar.getInstance(tx);
または
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(activity_main);
TextView tv0 = (TextView) findViewById(R.id.textView);
TextView tv1 = (TextView) findViewById(R.id.textView2);
TextView tv2 = (TextView) findViewById(R.id.textView3);
TextView tv3 = (TextView) findViewById(R.id.textView4);
TextView tv4 = (TextView) findViewById(R.id.textView5);
TextView tv5 = (TextView) findViewById(R.id.textView6);
TextView tv6 = (TextView) findViewById(R.id.textView7);
TextView tv7 = (TextView) findViewById(R.id.textView8);
TextView tv8 = (TextView) findViewById(R.id.textView9);
Calendar c = Calendar.getInstance();
tv1.setText(c.getTime().toString());
tv2.setText(TimeZone.getDefault().getID().toString());
tv3.setText(String.valueOf(c.get(Calendar.HOUR_OF_DAY)));
// tv3.setText(String.valueOf(c.get(Calendar.HOUR))); tv4.setText(String.valueOf(c.get(Calendar.MINUTE)));
tv5.setText(String.valueOf(c.get(Calendar.SECOND)));
tv6.setText(String.valueOf(c.get(Calendar.YEAR)));
tv7.setText(String.valueOf(c.get(Calendar.MONTH)));
tv8.setText(String.valueOf(c.get(Calendar.DATE)));
}
0 件のコメント:
コメントを投稿