package NFP.Algorithms; import seg.jUCMNav.nfp.generated.*; public class ConvertTime { private double srcValue; private DurationUnitKind srcUnit; private DurationUnitKind convertedUnit; private double convertedValue = 0; public double getConvertedValue(double srcValue, DurationUnitKind srcUnit, DurationUnitKind convertedUnit) { this.srcValue = srcValue; this.srcUnit = srcUnit; this.convertedUnit = convertedUnit; if(this.srcUnit==this.convertedUnit) return this.srcValue; switch (this.srcUnit) { case MICROSECONDS: switch (this.convertedUnit) { case SECONDS: convertedValue = this.srcValue*0.000001; break; case MINUTES: convertedValue = this.srcValue*1.67*0.00000001; break; case HOURS: convertedValue = this.srcValue*2.77*0.0000000001; break; default: break; } break; case SECONDS: switch (this.convertedUnit) { case MICROSECONDS: convertedValue = this.srcValue*1000000; break; case MINUTES: convertedValue = this.srcValue*0.0167; break; case HOURS: convertedValue = this.srcValue*0.000278; break; default: break; } break; case MINUTES: switch (this.convertedUnit) { case SECONDS: convertedValue = this.srcValue*60; break; case MICROSECONDS: convertedValue = this.srcValue*60000000; break; case HOURS: convertedValue = this.srcValue*0.0167; break; default: break; } break; case HOURS: switch (this.convertedUnit) { case SECONDS: convertedValue = this.srcValue*3600; break; case MINUTES: convertedValue = this.srcValue*60; break; case MICROSECONDS: convertedValue = this.srcValue*60*600000000; break; default: break; } break; default: break; } return convertedValue; } }