Java Code Examples for java.util.concurrent.TimeUnit.ordinal()

The following are Jave code examples for showing how to use ordinal() of the java.util.concurrent.TimeUnit class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: BRjLibs   File:   Source Code and License Vote up 5 votes
public TimeAmount compress() {
	TimeUnit lossless = this.unit;
	TimeUnit[] timeUnits = TimeUnit.values();
	for (int i = lossless.ordinal() + 1; i < timeUnits.length; i++) {
		TimeUnit timeUnit = timeUnits[i];

		//If do back and forth conversion is lossless
		if (unit.convert(timeUnit.convert(amount, unit), timeUnit) == amount) lossless = timeUnit;
		else break;

	return convertTo(lossless);