src/org/kocakosm/pitaya/time/Duration.java
public static Duration of(long amount, TimeUnit unit)
	{
		long duration = MILLISECONDS.convert(amount, unit);
		if (unit.convert(duration, MILLISECONDS) != amount) {
			throw new ArithmeticException(
				"Too large duration: " + amount + " " + unit);
		}
		return new Duration(duration);
	}
public static Duration of(long amount, TimeUnit unit)
	{
		long duration = MILLISECONDS.convert(amount, unit);
		if (unit.convert(duration, MILLISECONDS) != amount) {
			throw new ArithmeticException(
				"Too large duration: " + amount + " " + unit);
		}
		return new Duration(duration);
	}
public static Duration of ( long amount , TimeUnit unit ) { long duration = MILLISECONDS . convert ( amount , unit ) ; if ( unit . convert ( duration , MILLISECONDS ) != amount ) { throw new ArithmeticException ( "Too large duration: " + amount + " " + unit ) ; } return new Duration ( duration ) ; }
Creates a new {@code Duration} representing the given amount in the
given unit.

@param amount the amount.
@param unit the unit in which the amout is given.

@return the created {@code Duration} instance.

@throws NullPointerException if {@code unit} is {@code null}.
@throws ArithmeticException if the resulting duration is too large.
Creates a new { @code Duration } representing the given amount in the given unit .