TimeUnit.toSeconds works well when the result is > 1. However, because we're dealing with longs, if the result is between 0 and 1 exclusive, we get 0 instead. Is the a java SDK function that handles double conversions for us?
I understand that I can perform these conversion myself by multiplying or dividing by the appropriate double. However, it is error prone and does not read well. My preference is to use an existing function from the Java SDK, similar to Java's TimeUnit.
Minimal example demonstrating my situation:
import java.util.*;
import java.util.concurrent.*;
public class Main {
public static void main(String[] args) {
System.out.println(TimeUnit.MILLISECONDS.toSeconds(1));
}
}
Output:
0
I want a function that handles doubles that returns 0.001