I have a 5 minutes timer. In case i finish 30 seconds its shown 4:30 but i want set 30 seconds .
code to decrease time
String timeReminder= String.format(Locale.ENGLISH , "%02d:%02d" , TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished) , TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished)) );
timerText.setText(timeReminder);
i want only reminder time.
java.time
You can use
java.time.Duration
which is modelled on ISO-8601 standards and was introduced with Java-8 as part of JSR-310 implementation. With Java-9 some more convenience methods were introduced.Output:
Learn more about the modern date-time API from Trail: Date Time.