/** * 根据经度获取时区;例如121:+8;-121:-8;返回值为字符串(返回正数时候带+符号) * * @param currentLon * @return */ public static String caculateTimeZone(double currentLon) { int timeZone; int shangValue = (int) (currentLon / 15); double yushuValue = Math.abs(currentLon % 15); if (yushuValue <= 7.5) { timeZone = shangValue; } else { timeZone = shangValue + (currentLon > 0 ? 1 : -1); } Log.i(TAG, "caculateTimeZone timeZone:" + timeZone); getGMTUnixTime(timeZone); return timeZone >= 0 ? "+" + Math.abs(timeZone) : "-" + Math.abs(timeZone); }
Android GPS根据经度获取时区
最新推荐文章于 2024-04-12 17:59:55 发布