Double Timeunit Conversion

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 library 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 library, 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) {


Read More »

By: StackOverFlow - Tuesday, 13 March

Related Posts