fix: Locale format
This commit is contained in:
parent
decbd83316
commit
70c573eb81
@ -6,6 +6,7 @@ import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.Locale;
|
||||
|
||||
import eirb.pg203.utils.JSONFetcher;
|
||||
import org.json.JSONArray;
|
||||
@ -28,7 +29,7 @@ public class City {
|
||||
private static JSONObject getDataFromName(String cityName) throws IOException {
|
||||
StringBuilder result = new StringBuilder();
|
||||
URL url = URI.create(
|
||||
String.format("https://api-adresse.data.gouv.fr/search/?q=%s&autocomplete=0&limit=1",
|
||||
String.format(Locale.ENGLISH, "https://api-adresse.data.gouv.fr/search/?q=%s&autocomplete=0&limit=1",
|
||||
cityName
|
||||
)
|
||||
).toURL();
|
||||
@ -79,7 +80,7 @@ public class City {
|
||||
public String toString() {
|
||||
try {
|
||||
Coords coords = this.getCityCoords();
|
||||
return String.format(
|
||||
return String.format(Locale.ENGLISH,
|
||||
"City(%s, lat: %f, lon: %f)",
|
||||
this.cityName,
|
||||
coords.getLat(),
|
||||
@ -87,7 +88,7 @@ public class City {
|
||||
);
|
||||
}
|
||||
catch (IOException e) {
|
||||
return String.format(
|
||||
return String.format(Locale.ENGLISH,
|
||||
"City(%s, lat: Request failed, lon: Request Failed)",
|
||||
this.cityName
|
||||
);
|
||||
|
@ -10,6 +10,8 @@ import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import eirb.pg203.WeatherData.Condition;
|
||||
|
||||
// https://api.open-meteo.com/v1/forecast?latitude=52.52&longitude=13.41&hourly=temperature_2m
|
||||
@ -30,15 +32,14 @@ public class OpenMeteo implements WeatherDataAPI {
|
||||
// https://www.nodc.noaa.gov/archive/arc0021/0002199/1.1/data/0-data/HTML/WMO-CODE/WMO4677.HTM
|
||||
private JSONObject fetchWeather(int days, City city) throws IOException {
|
||||
URL url = URI.create(
|
||||
String.format(forecastBaseURL + "?latitude=%.2f&longitude=%.2f&forecast_days=%d&daily=" + dailyQuery,
|
||||
String.format(Locale.ENGLISH, forecastBaseURL + "?latitude=%.2f&longitude=%.2f&forecast_days=%d&daily=" + dailyQuery,
|
||||
city.getCityCoords().getLat(),
|
||||
city.getCityCoords().getLon(),
|
||||
days
|
||||
)
|
||||
).toURL();
|
||||
|
||||
JSONArray jsonArray = JSONFetcher.fetchArray(url);
|
||||
return jsonArray.getJSONObject(0);
|
||||
return JSONFetcher.fetch(url);
|
||||
}
|
||||
|
||||
private static Condition getConditionFromCode(int WMOCode) {
|
||||
|
@ -12,6 +12,8 @@ import java.time.DayOfWeek;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import eirb.pg203.WeatherData.Condition;
|
||||
|
||||
/**
|
||||
@ -27,7 +29,7 @@ public class OpenWeatherMap implements WeatherDataAPI {
|
||||
|
||||
private JSONObject fetchWeather(int days, City city) throws IOException {
|
||||
URL url = URI.create(
|
||||
String.format(forecastBaseURL + "?appid=%s&lat=%.2f&lon=%.2f&units=metric",
|
||||
String.format(Locale.ENGLISH, forecastBaseURL + "?appid=%s&lat=%.2f&lon=%.2f&units=metric",
|
||||
APIKey,
|
||||
city.getCityCoords().getLat(),
|
||||
city.getCityCoords().getLon(),
|
||||
|
@ -11,6 +11,7 @@ import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* WeatherAPI implementation
|
||||
@ -25,7 +26,7 @@ public class WeatherAPI implements WeatherDataAPI{
|
||||
|
||||
private JSONObject fetchWeather(int days, String city) throws IOException {
|
||||
URL url = URI.create(
|
||||
String.format(forecastBaseURL + "?key=%s&q=%s&days=%d",
|
||||
String.format(Locale.ENGLISH, forecastBaseURL + "?key=%s&q=%s&days=%d",
|
||||
this.weatherAPIKey,
|
||||
city,
|
||||
days
|
||||
|
@ -1,6 +1,7 @@
|
||||
package eirb.pg203;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
|
||||
/**
|
||||
@ -249,7 +250,7 @@ public class WeatherData {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%05.2f° %s %05.2fkm/h %06.2f° %s",
|
||||
return String.format(Locale.ENGLISH, "%05.2f° %s %05.2fkm/h %06.2f° %s",
|
||||
this.getTemp(),
|
||||
this.getCondition().toString(),
|
||||
this.getWindSpeed(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user