Class VolumeConverter

java.lang.Object
com.irurueta.units.VolumeConverter

public class VolumeConverter extends Object
Does volume conversions to different units. To prevent loss of accuracy, conversion should only be done as a final step before displaying volume measurements.
  • Field Details

    • CUBIC_METER_PER_CUBIC_CENTIMETER

      static final double CUBIC_METER_PER_CUBIC_CENTIMETER
      Number of cubic meters in 1 cubic centimeter.
      See Also:
    • CUBIC_METER_PER_MILLILITER

      static final double CUBIC_METER_PER_MILLILITER
      Number of cubic meters in 1 milliliter.
      See Also:
    • CUBIC_METER_PER_CUBIC_DECIMETER

      static final double CUBIC_METER_PER_CUBIC_DECIMETER
      Number of cubic meters in 1 cubic decimeter.
      See Also:
    • CUBIC_METER_PER_LITER

      static final double CUBIC_METER_PER_LITER
      Number of cubic meters in 1 liter.
      See Also:
    • CUBIC_METER_PER_HECTOLITER

      static final double CUBIC_METER_PER_HECTOLITER
      Number of cubic meters in 1 hectoliter.
      See Also:
    • CUBIC_METER_PER_CUBIC_INCH

      static final double CUBIC_METER_PER_CUBIC_INCH
      Number of cubic meters in 1 cubic inch.
      See Also:
    • CUBIC_METER_PER_PINT

      static final double CUBIC_METER_PER_PINT
      Number of cubic meters in 1 pint.
      See Also:
    • CUBIC_METER_PER_GALLON

      static final double CUBIC_METER_PER_GALLON
      Number of cubic meters in 1 gallon.
      See Also:
    • CUBIC_METER_PER_CUBIC_FOOT

      static final double CUBIC_METER_PER_CUBIC_FOOT
      Number of cubic meters in 1 cubic foot.
      See Also:
    • CUBIC_METER_PER_BARREL

      static final double CUBIC_METER_PER_BARREL
      Number of cubic meters in 1 barrel.
      See Also:
  • Constructor Details

    • VolumeConverter

      private VolumeConverter()
      Constructor. Prevents instantiation of helper class.
  • Method Details

    • convert

      public static void convert(Volume input, Volume output)
      Converts a volume in provided output volume unit.
      Parameters:
      input - input volume to be converted.
      output - output volume where result will be stored and containing output unit.
    • convertAndReturnNew

      public static Volume convertAndReturnNew(Volume input, VolumeUnit outputUnit)
      Converts a volume to requested output unit.
      Parameters:
      input - input volume to be converted.
      outputUnit - requested output unit.
      Returns:
      converted volume.
    • convert

      public static void convert(Volume volume, VolumeUnit outputUnit)
      Converts and updates a volume to requested output unit.
      Parameters:
      volume - input volume to be converted and updated.
      outputUnit - requested output unit.
    • convert

      public static void convert(Volume input, VolumeUnit outputUnit, Volume result)
      Converts a volume to requested output unit.
      Parameters:
      input - input volume to be converted.
      outputUnit - requested output unit.
      result - volume instance where result will be stored.
    • convert

      public static Number convert(Number input, VolumeUnit inputUnit, VolumeUnit outputUnit)
      Converts a volume value from input unit to provided output unit.
      Parameters:
      input - volume value.
      inputUnit - input volume unit.
      outputUnit - output volume unit.
      Returns:
      converted volume value.
    • convert

      public static double convert(double input, VolumeUnit inputUnit, VolumeUnit outputUnit)
      Converts a volume value from input unit to provided output unit.
      Parameters:
      input - volume value.
      inputUnit - input volume unit.
      outputUnit - output volume unit.
      Returns:
      converted volume value.
    • cubicMeterToCubicCentimeter

      public static double cubicMeterToCubicCentimeter(double cubicMeter)
      Converts provided cubic meter value to cubic centimeters.
      Parameters:
      cubicMeter - cubic meter value.
      Returns:
      same volume converted to cubic centimeters.
    • cubicCentimeterToCubicMeter

      public static double cubicCentimeterToCubicMeter(double cubicCentimeter)
      Converts provided cubic centimeter value to cubic meters.
      Parameters:
      cubicCentimeter - cubic centimeter value.
      Returns:
      same volume converted to cubic meters.
    • cubicMeterToMilliliter

      public static double cubicMeterToMilliliter(double cubicMeter)
      Converts provided cubic meter value to milliliters.
      Parameters:
      cubicMeter - cubic meter value.
      Returns:
      same volume converted to milliliters.
    • milliliterToCubicMeter

      public static double milliliterToCubicMeter(double milliliter)
      Converts provided milliliter value to cubic meters.
      Parameters:
      milliliter - milliliter value.
      Returns:
      same volume converted to cubic meters.
    • cubicMeterToCubicDecimeter

      public static double cubicMeterToCubicDecimeter(double cubicMeter)
      Converts provided cubic meter value to cubic decimeters.
      Parameters:
      cubicMeter - cubic meter value.
      Returns:
      same volume converted to cubic decimeters.
    • cubicDecimeterToCubicMeter

      public static double cubicDecimeterToCubicMeter(double cubicDecimeter)
      Converts provided cubic decimeter value to cubic meters.
      Parameters:
      cubicDecimeter - cubic decimeter value.
      Returns:
      same volume converted to cubic meters.
    • cubicMeterToLiter

      public static double cubicMeterToLiter(double cubicMeter)
      Converts provided cubic meter value to liters.
      Parameters:
      cubicMeter - cubic meter value.
      Returns:
      same volume converted to liters.
    • literToCubicMeter

      public static double literToCubicMeter(double liter)
      Converts provided liter value to cubic meters.
      Parameters:
      liter - liter value.
      Returns:
      same volume converted to cubic meters.
    • cubicMeterToHectoliter

      public static double cubicMeterToHectoliter(double cubicMeter)
      Converts provided cubic meter value to hectoliters.
      Parameters:
      cubicMeter - cubic meter value.
      Returns:
      same volume converted to hectoliters.
    • hectoliterToCubicMeter

      public static double hectoliterToCubicMeter(double hectoliter)
      Converts provided hectoliter value to cubic meters.
      Parameters:
      hectoliter - hectoliter value.
      Returns:
      same volume converted to cubic meters.
    • cubicMeterToCubicInch

      public static double cubicMeterToCubicInch(double cubicMeter)
      Converts provided cubic meter value to cubic inches.
      Parameters:
      cubicMeter - cubic meter value.
      Returns:
      same volume converted to cubic inches.
    • cubicInchToCubicMeter

      public static double cubicInchToCubicMeter(double cubicInch)
      Converts provided cubic inch value to cubic meters.
      Parameters:
      cubicInch - cubic inch value.
      Returns:
      same volume converted to cubic meters.
    • cubicMeterToPint

      public static double cubicMeterToPint(double cubicMeter)
      Converts provided cubic meter value to pints.
      Parameters:
      cubicMeter - cubic meter value.
      Returns:
      same volume converted to pints.
    • pintToCubicMeter

      public static double pintToCubicMeter(double pint)
      Converts provided pint value to cubic meters.
      Parameters:
      pint - pint value.
      Returns:
      same volume converted to cubic meters.
    • cubicMeterToGallon

      public static double cubicMeterToGallon(double cubicMeter)
      Converts provided cubic meter value to gallons.
      Parameters:
      cubicMeter - cubic meter value.
      Returns:
      same volume converted to gallons.
    • gallonToCubicMeter

      public static double gallonToCubicMeter(double gallon)
      Converts provided gallon value to cubic meters.
      Parameters:
      gallon - gallon value.
      Returns:
      same volume converted to cubic meters.
    • cubicMeterToCubicFoot

      public static double cubicMeterToCubicFoot(double cubicMeter)
      Converts provided cubic meter value to cubic feet.
      Parameters:
      cubicMeter - cubic meter value.
      Returns:
      same volume converted to cubic feet.
    • cubicFootToCubicMeter

      public static double cubicFootToCubicMeter(double cubicFoot)
      Converts provided cubic foot value to cubic meters.
      Parameters:
      cubicFoot - cubic foot value.
      Returns:
      same volume converted to cubic meters.
    • cubicMeterToBarrel

      public static double cubicMeterToBarrel(double cubicMeter)
      Converts provided cubic meter value to barrels.
      Parameters:
      cubicMeter - cubic meter value.
      Returns:
      same volume converted to barrels.
    • barrelToCubicMeter

      public static double barrelToCubicMeter(double barrel)
      Converts provided barrel value to cubic meters.
      Parameters:
      barrel - barrel value.
      Returns:
      same volume converted to cubic meters.