Understanding TimeUnit

I took a look into TimeUnit and toMillis() method.

 public long toMillis(long paramLong)
 {
    throw new AbstractMethodError();
 }

toMillis() method do nothing other than throw an AbstractMethodError exception.

So, How does toMillis() method convert seconds, minutes, etc to milliseconds?

Jon Skeet
people
quotationmark

Each value within TimeUnit overrides it, basically. You never end up calling that implementation, because you never have a reference to an object of type TimeUnit - it's always a subclass representing one of the values.

people

See more on this question at Stackoverflow