Questions tagged [timeunit]

55 questions
0
votes
3 answers

Why is the sleep method affecting/not showing my updated JTextArea on the panel?

I have a window that has various panels. On one panel, I have a JTextArea called dogTalk where I update its text. Upon user's click of a button, I want the text to add what I have mentioned below in setText. I used the sleep method so that the…
user1217
  • 53
  • 1
  • 5
0
votes
1 answer

Converting a code from API 9 to API 8 ( TimeUnit)

I am trying to create a countdown timer that works with Android 2.2 (API 8). I found this code but it only works with API 9 and above. How can I make this code work in API 8? //API 9 and above public class CountClass extends CountDownTimer{ …
0
votes
1 answer

Java - change Minutes and Seconds to time format? (mm:ss)

i started with total milliseconds, which I've converted to to total minutes and total seconds: long minutes = TimeUnit.MILLISECONDS.toMinutes(itemDuration); long seconds = TimeUnit.MILLISECONDS.toSeconds(itemDuration) -…
Daniel Kim
  • 267
  • 3
  • 16
0
votes
1 answer

Ruby analog Java TimeUnit

So in java we have TimeUnit enum with awesome methods. Any analog in Ruby language? I need converters seconds to milliseconds, milliseconds to days and so one
0
votes
5 answers

how I can exit from a loop in one second using Runtime?

how I can exit from a loop in one second using Runtime? I want use this code public class test { public static void main(String[] args) { Runtime runtime = Runtime.getRuntime(); long usedMemory =…
0
votes
1 answer

Fatal Exception in TimeUnit

I am running my application on emulator with Android 2.2 and API level 8. I have tested the following 2 lines in my code: long diffInDays = TimeUnit.MILLISECONDS.toDays(diffInMs); // API Level 9 long diffInDays =…
Bob
  • 22,810
  • 38
  • 143
  • 225
-1
votes
2 answers

How to get Elapsed time in Android TimeUnit

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) ,…
Ganesh MB
  • 1,109
  • 2
  • 14
  • 27
-1
votes
1 answer

Need help making a delay in a javafx application

I am making a javafx application that simulates a robot vacuum. I want it to be automated so it would vacuum the environment by itself. I need to insert a delay so a human can see the steps the vacuum is taking as it traverses the environment. So…
-1
votes
1 answer

CANCELED - TimeUnit.MINUTES.convert() method functionality

Well I'm trying to get diference between times and I'm using TimeUnit.XXX.convert(). Here's my piece of test code: SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); Date d1 = new Date(); Date d2 = new Date(); try…
Joabe Lucena
  • 792
  • 8
  • 21
-3
votes
2 answers

Why is a try catch statement required?

Why is a try/catch exception handling statement required in Java for the below line: TimeUnit.MILLISECONDS.sleep(250); I just want my code to sleep for 250 milliseconds before executing the next line. Why is a try-catch statement required? I can’t…
1 2 3
4