我想将英里换成米?和其他单位指标? 我尝试了很多变种来改变价值,但它没有帮助我,请有人能做到吗?如果有必要我可以分享我的所有代码,对不起我的英语。
我的代码请帮忙。
Double speedInMilesPerHour = location.getSpeed()* 3.6; //inMeters
requestParams.put("speed", Integer.toString(speedInMilesPerHour.intValue()));
try {
requestParams.put("date", URLEncoder.encode(dateFormat.format(date), "UTF-8"));
} catch (UnsupportedEncodingException e) {}
requestParams.put("locationmethod", location.getProvider());
if (totalDistanceInMeters > 0) {
requestParams.put("distance", String.format("%.1f", totalDistanceInMeters / 1609)); // in miles,
} else {
requestParams.put("distance", "0.0"); // in miles
}
requestParams.put("username", sharedPreferences.getString("userName", ""));
requestParams.put("phonenumber", sharedPreferences.getString("appID", "")); // uuid
requestParams.put("sessionid", sharedPreferences.getString("sessionID", "")); // uuid
Double accuracyInFeet = location.getAccuracy()* 3.28;
requestParams.put("accuracy", Integer.toString(accuracyInFeet.intValue()));
Double altitudeInFeet = location.getAltitude() * 3.28;
requestParams.put("extrainfo", Integer.toString(altitudeInFeet.intValue()));
答案 0 :(得分:1)
您可以编写适用于双打的简单转换方法:
public static double metersToMiles(double meters) {
return meters / 1609.3440057765;
}
public static double milesToMeters(double miles) {
return 0.0006213711 * miles;
}