public long convert(final long aSourceDuration, final CalendarDateUnit aSourceUnit) { if ((myTimeUnit != null) && (aSourceUnit.getTimeUnit() != null)) { return myTimeUnit.convert(aSourceDuration, aSourceUnit.getTimeUnit()); } else { return Math.round(this.convert((double) aSourceDuration, aSourceUnit)); } }
public double convert( final double aSourceDurationMeasure, final CalendarDateUnit aSourceDurationUnit) { final double tmpSourceSize = aSourceDurationUnit.size(); final double tmpDestinationSize = mySize; if (tmpSourceSize > tmpDestinationSize) { final double tmpScale = tmpSourceSize / tmpDestinationSize; return aSourceDurationMeasure * tmpScale; } else if (tmpSourceSize < tmpDestinationSize) { final double tmpScale = tmpDestinationSize / tmpSourceSize; return aSourceDurationMeasure / tmpScale; } else { return aSourceDurationMeasure; } }