Java Number Convert convertToInchesOfMercury(double altimeterSetting, String unit)

Here you can find the source of convertToInchesOfMercury(double altimeterSetting, String unit)

Description

convert To Inches Of Mercury

License

Open Source License

Declaration

public static Double convertToInchesOfMercury(double altimeterSetting, String unit) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
    public static Double convertToInchesOfMercury(double altimeterSetting, String unit) {
        if ("hPa".equalsIgnoreCase(unit) || "http://opengis.net/def/uom/UCUM/0/hPa".equalsIgnoreCase(unit)) {
            double convertedVal = 0.0295299830714 * altimeterSetting;
            return round(convertedVal, 2);
        }/*from   www  .  ja v  a2s  .  c o m*/
        //TODO
        return null;
    }

    public static double round(double value, int places) {
        if (places < 0)
            throw new IllegalArgumentException();

        BigDecimal bd = new BigDecimal(value);
        bd = bd.setScale(places, RoundingMode.HALF_UP);
        return bd.doubleValue();
    }
}

Related

  1. convertSizeToMB(long sizeInBytes)
  2. convertsToLong(double v)
  3. convertStringToObjectWrapper(String className, String value)
  4. convertToDecimal(Number n)
  5. convertToHours(long workingDuration)
  6. convertToJBPM(Object value)
  7. convertToKg(int value)
  8. convertToLong(String decimal, int precision)
  9. ConvertToMeters(double distance)