{"action":"opened","issue":{"url":"https://api.github.com/repos/rosema2012/AC2018/issues/37","repository_url":"https://api.github.com/repos/rosema2012/AC2018","labels_url":"https://api.github.com/repos/rosema2012/AC2018/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/rosema2012/AC2018/issues/37/comments","events_url":"https://api.github.com/repos/rosema2012/AC2018/issues/37/events","html_url":"https://github.com/rosema2012/AC2018/issues/37","id":383206024,"node_id":"MDU6SXNzdWUzODMyMDYwMjQ=","number":37,"title":"Tema3(Json)Ejercicio8y9","user":{"login":"rosema2012","id":36199346,"node_id":"MDQ6VXNlcjM2MTk5MzQ2","avatar_url":"https://avatars2.githubusercontent.com/u/36199346?v=4","gravatar_id":"","url":"https://api.github.com/users/rosema2012","html_url":"https://github.com/rosema2012","followers_url":"https://api.github.com/users/rosema2012/followers","following_url":"https://api.github.com/users/rosema2012/following{/other_user}","gists_url":"https://api.github.com/users/rosema2012/gists{/gist_id}","starred_url":"https://api.github.com/users/rosema2012/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rosema2012/subscriptions","organizations_url":"https://api.github.com/users/rosema2012/orgs","repos_url":"https://api.github.com/users/rosema2012/repos","events_url":"https://api.github.com/users/rosema2012/events{/privacy}","received_events_url":"https://api.github.com/users/rosema2012/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-21T16:44:59Z","updated_at":"2018-11-21T16:44:59Z","closed_at":null,"author_association":"OWNER","body":"package json;\r\n\r\nimport java.time.Instant;\r\nimport java.time.ZoneId;\r\nimport java.time.format.DateTimeFormatter;\r\nimport javax.json.JsonObject;\r\n\r\n/**\r\n * @author David Carrera Otero\r\n */\r\npublic class Tema3JsonEjercicio8y9 extends Tema3JsonEjercicio2 {\r\n\r\n    //------- Ejercicio 8 -------\r\n    public JsonObject datosCiudad(String ciudad) {\r\n        JsonObject json = null;\r\n        json = (JsonObject) leeJSON(\"http://api.openweathermap.org/data/2.5/weather?q=\" + ciudad + \",es&lang=es&APPID=8f8dccaf02657071004202f05c1fdce0\");\r\n        return json;\r\n    }\r\n\r\n    public String unixTimeToString(long unixTime) {\r\n        final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(\"yyyy-MM-dd HH:mm:ss\");\r\n        return Instant.ofEpochSecond(unixTime).atZone(ZoneId.of(\"GMT+1\")).format(formatter);\r\n    }\r\n\r\n    //------ Ejercicio 9 -------\r\n    public JsonObject datosCiudadProximas(String lon, String lat) {\r\n        JsonObject json = null;\r\n        json = (JsonObject) leeJSON(\"http://api.openweathermap.org/data/2.5/find?lat=42.232819&lon=-8.72264&cnt=20&APPID=8f8dccaf02657071004202f05c1fdce0\");\r\n        return json;\r\n    }\r\n\r\n    public int convertirCelsius(int kel) {\r\n        int celsius = (int) (kel - 273.15);\r\n        return celsius;\r\n    }\r\n\r\n    public static void main(String[] args) {\r\n        String ciudad = \"Lugo\";\r\n        JsonObject ciudades;\r\n        Tema3JsonEjercicio8y9 eje = new Tema3JsonEjercicio8y9();\r\n        System.out.println(\"-----Datos Meteorlogicos-----\\n\"\r\n                + \"Temperatura: \" + eje.convertirCelsius(eje.datosCiudad(ciudad).getJsonObject(\"main\").getInt(\"temp\")) + \"ºC\\n\"\r\n                + \"Humedad: \" + eje.datosCiudad(ciudad).getJsonObject(\"main\").getInt(\"humidity\") + \"%\\n\"\r\n                + \"Probabilidad de cielo nublado: \" + eje.datosCiudad(ciudad).getJsonObject(\"clouds\").getInt(\"all\") + \"%\\n\"\r\n                + \"Velocidad del viento: \" + eje.datosCiudad(ciudad).getJsonObject(\"wind\").getJsonNumber(\"speed\") + \"\\n\"\r\n                + \"Pronostico del tiempo: (\" + eje.datosCiudad(ciudad).getJsonArray(\"weather\").getJsonObject(0).getString(\"main\") + \")\"\r\n                + \"(\" + eje.datosCiudad(ciudad).getJsonArray(\"weather\").getJsonObject(0).getString(\"description\") + \")\\n\"\r\n                + \"Fecha actual: \" + eje.unixTimeToString(Long.valueOf(eje.datosCiudad(ciudad).getJsonNumber(\"dt\").toString())));\r\n\r\n        //----------------------------------------------------------------------------------------\r\n            ciudades = eje.datosCiudadProximas(\r\n                String.valueOf(eje.datosCiudad(ciudad).getJsonObject(\"coord\").getJsonNumber(\"lon\")),\r\n                String.valueOf(eje.datosCiudad(ciudad).getJsonObject(\"coord\").getJsonNumber(\"lat\"))\r\n        );\r\n\r\n       // System.out.println(\"Temperatura: \"+(((ciudades.getJsonArray(\"list\").getJsonObject(0).getJsonObject(\"main\").getInt(\"temp\"))+\"º\\n\"\r\n//                + \"Humedad: \" + ciudades.getJsonArray(\"list\").getJsonObject(0).getJsonObject(\"main\").getInt(\"humidity\") + \"%\\n\"\r\n//                + \"          + \\\"Probabilidad de cielo nublado: \\\" + eje.datosCiudad(ciudad).getJsonObject(\\\"clouds\\\").getInt(\\\"all\\\") + \\\"%\\\\n\\\"\\n\" +\r\n//\"               + \\\"Velocidad del viento: \\\" + eje.datosCiudad(ciudad).getJsonObject(\\\"wind\\\").getJsonNumber(\\\"speed\\\") + \\\"\\\\n\\\"\\n\" +\r\n//\"               + \\\"Pronostico del tiempo: (\\\" + eje.datosCiudad(ciudad).getJsonArray(\\\"weather\\\").getJsonObject(0).getString(\\\"main\\\") + \\\")\\\"\\n\" +\r\n//\"               + \\\"(\\\" + eje.datosCiudad(ciudad).getJsonArray(\\\"weather\\\").getJsonObject(0).getString(\\\"description\\\") + \\\")\\\\n\\\"\\n\" +\r\n//\"               + \\\"Fecha actual: \\\" + eje.unixTimeToString(Long.valueOf(eje.datosCiudad(ciudad).getJsonNumber(\\\"dt\\\").toString())));\")));\r\n        \r\n    }\r\n}\r\n"}}
{"actor":{"display_login":"rosema2012"}}