/** * 将小数度数转换为度分秒格式 * @param numStr (主要用于图片中存储经纬度) * @return */ public static String convertToSexagesimal(String numStr){ double num = Double.parseDouble(numStr); int du=(int)Math.floor(Math.abs(num)); //获取整数部分 double temp=getdPoint(Math.abs(num))*60; int fen=(int)Math.floor(temp); //获取整数部分 double miao=getdPoint(temp)*60; if(num<0) return "-"+du+"/1,"+fen+"/1,"+miao+"/1"; return du+"/1,"+fen+"/1,"+miao+"/1"; } //获取小数部分 private static double getdPoint(double num){ double d = num; int fInt = (int) d; BigDecimal b1 = new BigDecimal(Double.toString(d)); BigDecimal b2 = new BigDecimal(Integer.toString(fInt)); double dPoint = b1.subtract(b2).floatValue(); return dPoint; }