I'm using this method to convert minutes into time (hh:mm:ss)
public static String time(double m){
double t = m;
int hours = (int)t / 60;
int minutes = (int)t % 60;
double seconds = (t - Math.floor(t)) * 60;
System.out.println(seconds);
if (seconds > 59){
seconds = 00;
minutes++;
}
String myFormat = seconds >= 10 ? "%d:%02d:%.0f" : "%d:%02d:%.0f";
String time = String.format(myFormat, hours, minutes, seconds);
return time;
}
the time will return as a string, then I will post it into a jTable, the jTable has more than 100 timers that should countdown too, I am thinking about if the system time increased 1 second all timers should decreased 1 second.
any help? thank you
EDIT Shows example of how to color cells based on the time, if time remaining is less or equal to five minutes, the cell becomes red.
First, you need to create a custom renderer class, which will be used by your table. This class will contain the logic for coloring of cells, eighter red, or default white:
Next, you need to tell your table to use this new custom renderer:
And that's it! Now the cells will be red or not depending on the time.
I edited the original answer with this modification, you can test and run the code below:
Adapt this to your needs.