Here you can find the source of millisToDuration(final int val, final TimeUnit unit)
Parameter | Description |
---|---|
IllegalArgumentException | if the unit is null. Thrown via APIgetter methods such as Transaction.getLockTimeout. |
public static long millisToDuration(final int val, final TimeUnit unit)
//package com.java2s; /*-// w ww. j a v a 2 s . c o m * See the file LICENSE for redistribution information. * * Copyright (c) 2002-2010 Oracle. All rights reserved. * */ import java.util.concurrent.TimeUnit; public class Main { /** * Converts the given duration value in milliseconds to the given unit. * * @throws IllegalArgumentException if the unit is null. Thrown via API * getter methods such as Transaction.getLockTimeout. */ public static long millisToDuration(final int val, final TimeUnit unit) { if (unit == null) { throw new IllegalArgumentException("TimeUnit argument may not be null"); } return unit.convert(val, TimeUnit.MILLISECONDS); } }