Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.erprasetyo.myasynctaskloader;
- import org.json.JSONObject;
- import java.text.DecimalFormat;
- public class WeatherItems {
- private int id;
- private String nama;
- private String curentWeather;
- private String description;
- private String temperature;
- public WeatherItems(JSONObject object) {
- try {
- int id = object.getInt("id");
- String name = object.getString("name");
- String currentWeather = object.getJSONArray("weather").getJSONObject(0).getString("main");
- double tempInKelvin = object.getJSONObject("main").getDouble("temp");
- double tempInCelsius = tempInKelvin - 273;
- String temperature = new DecimalFormat("##.##").format(tempInCelsius);
- this.id = id;
- this.nama = name;
- this.curentWeather = currentWeather;
- this.description = description;
- this.temperature = temperature;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getNama() {
- return nama;
- }
- public void setNama(String nama) {
- this.nama = nama;
- }
- public String getCurentWeather() {
- return curentWeather;
- }
- public void setCurentWeather(String currentWeather) {
- this.curentWeather = currentWeather;
- }
- public String getDescription() {
- return description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
- public String getTemperature() {
- return temperature;
- }
- public void setTemperature(String temperature) {
- this.temperature = temperature;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement