-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathTempUnitConverter.java
More file actions
33 lines (28 loc) · 837 Bytes
/
TempUnitConverter.java
File metadata and controls
33 lines (28 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package github.vatsal.easyweather.Helper;
/**
* Created by
* --Vatsal Bajpai on
* --26/06/16 at
* --7:13 PM in
*/
public class TempUnitConverter {
private static final double ABSOLUTE_ZERO = 273.15;
public static Double convertToCelsius(String kelvin) throws NumberFormatException {
double inKelvin;
try {
inKelvin = Double.parseDouble(kelvin);
} catch (NumberFormatException e) {
throw e;
}
return inKelvin - ABSOLUTE_ZERO;
}
public static Double convertToFahrenheit(String kelvin) throws NumberFormatException {
double inKelvin;
try {
inKelvin = Double.parseDouble(kelvin);
} catch (NumberFormatException e) {
throw e;
}
return (inKelvin - ABSOLUTE_ZERO) * 1.8000 + 32.00;
}
}