Here you can find the source of convertToInchesOfMercury(double altimeterSetting, String unit)
public static Double convertToInchesOfMercury(double altimeterSetting, String unit)
//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(); } }