digitalClockTv = (TextView) findViewById(R.id.digitalClockTv); countDownTimer = new CountDownTimer(1000000000, 1000) { public void onTick(long millisUntilFinished) { String hour, minit, sec; Calendar c = Calendar.getInstance(); hour = String.valueOf(c.get(Calendar.HOUR)); minit = String.valueOf(c.get(Calendar.MINUTE)); sec = String.valueOf(c.get(Calendar.SECOND)); int a = c.get(Calendar.AM_PM); if (hour.length() == 1) { hour = getString(R.string.zero) + hour; } if (minit.length() == 1) { minit = getString(R.string.zero) + minit; } if (sec.length() == 1) { sec = getString(R.string.zero) + sec; } if (a == Calendar.AM) { digitalClockTv.setText(hour + getString(R.string.colon) + minit + getString(R.string.colon) + sec + getString(R.string.am)); } else { digitalClockTv.setText(hour + getString(R.string.colon) + minit + getString(R.string.colon) + sec + getString(R.string.pm)); } } public void onFinish() { } }; countDownTimer.start();
Thank You
No comments:
Post a Comment