Class EnergyConverter

java.lang.Object
com.irurueta.units.EnergyConverter

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

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final double
    Number of joules in 1 International Table BTU.
    (package private) static final double
    Number of joules in 1 thermochemical calorie.
    (package private) static final double
    Number of joules in 1 thermochemical kilocalorie.
    (package private) static final double
    Number of joules in 1 kilojoule.
    (package private) static final double
    Number of joules in 1 kilowatt hour.
    (package private) static final double
    Number of joules in 1 megajoule.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    btuToJoule(double btu)
    Converts provided BTU value to joules.
    static double
    calorieToJoule(double calorie)
    Converts provided calorie value to joules.
    static double
    convert(double input, EnergyUnit inputUnit, EnergyUnit outputUnit)
    Converts an energy value from input unit to provided output unit.
    static void
    convert(Energy input, Energy output)
    Converts an energy instance to provided output energy unit.
    static void
    convert(Energy energy, EnergyUnit outputUnit)
    Converts and updates an energy to requested output unit.
    static void
    convert(Energy input, EnergyUnit outputUnit, Energy result)
    Converts an energy to requested output unit.
    static Number
    convert(Number input, EnergyUnit inputUnit, EnergyUnit outputUnit)
    Converts an energy value from input unit to provided output unit.
    static Energy
    Converts an energy instance to requested output unit.
    static double
    jouleToBtu(double joule)
    Converts provided joules value to BTU.
    static double
    jouleToCalorie(double joule)
    Converts provided joules value to calorie.
    static double
    jouleToKilocalorie(double joule)
    Converts provided joules value to kilocalorie.
    static double
    jouleToKilojoule(double joule)
    Converts provided joules value to kilojoule.
    static double
    jouleToKilowattHour(double joule)
    Converts provided joules value to kilowatt hour.
    static double
    jouleToMegajoule(double joule)
    Converts provided joules value to megajoule.
    static double
    kilocalorieToJoule(double kilocalorie)
    Converts provided kilocalorie value to joules.
    static double
    kilojouleToJoule(double kilojoule)
    Converts provided kilojoule value to joules.
    static double
    kilowattHourToJoule(double kilowattHour)
    Converts provided kilowatt hour value to joules.
    static double
    megajouleToJoule(double megajoule)
    Converts provided megajoule value to joules.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • JOULES_PER_KILOJOULE

      static final double JOULES_PER_KILOJOULE
      Number of joules in 1 kilojoule.
      See Also:
    • JOULES_PER_MEGAJOULE

      static final double JOULES_PER_MEGAJOULE
      Number of joules in 1 megajoule.
      See Also:
    • JOULES_PER_CALORIE

      static final double JOULES_PER_CALORIE
      Number of joules in 1 thermochemical calorie.
      See Also:
    • JOULES_PER_KILOCALORIE

      static final double JOULES_PER_KILOCALORIE
      Number of joules in 1 thermochemical kilocalorie.
      See Also:
    • JOULES_PER_KILOWATT_HOUR

      static final double JOULES_PER_KILOWATT_HOUR
      Number of joules in 1 kilowatt hour.
      See Also:
    • JOULES_PER_BTU

      static final double JOULES_PER_BTU
      Number of joules in 1 International Table BTU.
      See Also:
  • Constructor Details

    • EnergyConverter

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

    • convert

      public static void convert(Energy input, Energy output)
      Converts an energy instance to provided output energy unit.
      Parameters:
      input - input energy to be converted.
      output - output energy where result will be stored containing output unit.
    • convertAndReturnNew

      public static Energy convertAndReturnNew(Energy input, EnergyUnit outputUnit)
      Converts an energy instance to requested output unit.
      Parameters:
      input - input energy to be converted.
      outputUnit - requested output unit.
      Returns:
      converted energy.
    • convert

      public static void convert(Energy energy, EnergyUnit outputUnit)
      Converts and updates an energy to requested output unit.
      Parameters:
      energy - input energy to be converted and updated.
      outputUnit - requested output unit.
    • convert

      public static void convert(Energy input, EnergyUnit outputUnit, Energy result)
      Converts an energy to requested output unit.
      Parameters:
      input - input energy to be converted.
      outputUnit - requested output unit.
      result - energy instance where result will be stored.
    • convert

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

      public static double convert(double input, EnergyUnit inputUnit, EnergyUnit outputUnit)
      Converts an energy value from input unit to provided output unit.
      Parameters:
      input - energy value.
      inputUnit - input energy unit.
      outputUnit - output energy unit.
      Returns:
      converted energy value.
    • kilojouleToJoule

      public static double kilojouleToJoule(double kilojoule)
      Converts provided kilojoule value to joules.
      Parameters:
      kilojoule - kilojoule value.
      Returns:
      same energy converted to joules.
    • jouleToKilojoule

      public static double jouleToKilojoule(double joule)
      Converts provided joules value to kilojoule.
      Parameters:
      joule - joules value.
      Returns:
      same energy converted to kilojoule.
    • megajouleToJoule

      public static double megajouleToJoule(double megajoule)
      Converts provided megajoule value to joules.
      Parameters:
      megajoule - megajoule value.
      Returns:
      same energy converted to joules.
    • jouleToMegajoule

      public static double jouleToMegajoule(double joule)
      Converts provided joules value to megajoule.
      Parameters:
      joule - joules value.
      Returns:
      same energy converted to megajoule.
    • calorieToJoule

      public static double calorieToJoule(double calorie)
      Converts provided calorie value to joules.
      Parameters:
      calorie - calorie value.
      Returns:
      same energy converted to joules.
    • jouleToCalorie

      public static double jouleToCalorie(double joule)
      Converts provided joules value to calorie.
      Parameters:
      joule - joules value.
      Returns:
      same energy converted to calorie.
    • kilocalorieToJoule

      public static double kilocalorieToJoule(double kilocalorie)
      Converts provided kilocalorie value to joules.
      Parameters:
      kilocalorie - kilocalorie value.
      Returns:
      same energy converted to joules.
    • jouleToKilocalorie

      public static double jouleToKilocalorie(double joule)
      Converts provided joules value to kilocalorie.
      Parameters:
      joule - joules value.
      Returns:
      same energy converted to kilocalorie.
    • kilowattHourToJoule

      public static double kilowattHourToJoule(double kilowattHour)
      Converts provided kilowatt hour value to joules.
      Parameters:
      kilowattHour - kilowatt hour value.
      Returns:
      same energy converted to joules.
    • jouleToKilowattHour

      public static double jouleToKilowattHour(double joule)
      Converts provided joules value to kilowatt hour.
      Parameters:
      joule - joules value.
      Returns:
      same energy converted to kilowatt hour.
    • btuToJoule

      public static double btuToJoule(double btu)
      Converts provided BTU value to joules.
      Parameters:
      btu - BTU value.
      Returns:
      same energy converted to joules.
    • jouleToBtu

      public static double jouleToBtu(double joule)
      Converts provided joules value to BTU.
      Parameters:
      joule - joules value.
      Returns:
      same energy converted to BTU.